如果我使用EC2在AWS ECS中运行容器,那么我可以访问正在运行的容器并执行任何命令.
即.
docker exec -it <containerid> <command>
如何使用Fargate在AWS ECS中运行容器或访问容器中运行命令?
我为我的应用程序创建了API网关,它将充当其他微服务的前端控制器。在生产设置中,我将Nginx用户用作网关的反向代理
API网关在端口8080上运行
Nginx的配置如下
gateway-api.conf:
server {
listen 80;
server_name api.example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://localhost:30010/;
keepalive_timeout 500s;
}
keepalive_timeout 500s;
access_log /var/log/nginx/api.log;
error_log /var/log/nginx/api_error.log;
}
Run Code Online (Sandbox Code Playgroud)
nginx.conf中的超时设置
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
Run Code Online (Sandbox Code Playgroud)
Spring Cloud Gateway Gradle文件:
compile('org.springframework.cloud:spring-cloud-starter-gateway')
compile('org.springframework.cloud:spring-cloud-starter-openfeign')
compile("org.springframework.boot:spring-boot-starter-actuator")
compile('org.springframework.boot:spring-boot-starter-security')
springBootVersion=2.0.3.RELEASE
springDMPVersion=1.0.4.RELEASE
springPlatformBomVersion=Cairo-SR2
springCloudVersion=Finchley.RELEASE
Run Code Online (Sandbox Code Playgroud)
网关应用程序:
@SpringBootApplication
@ComponentScan(basePackages = {"com.example"})
@EntityScan(basePackages = {"com.example"})
@EnableFeignClients(basePackages = "com.example")
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args); …
Run Code Online (Sandbox Code Playgroud) java nginx spring-cloud nginx-reverse-proxy spring-cloud-gateway
根据这篇文章,LinkedIn 支持用于链接预览的开放图元标记。我在 HTML 页面的 head 部分添加了所有必需的元标记。
IE。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- Primary Meta Tags -->
<title>This is sample title</title>
<!-- Open Graph / Facebook / LinkedIn -->
<meta property="og:type" content="website">
<meta property="og:title" content="This is sample title">
<meta property="og:description" content='sample description'>
<meta property="og:image" content="image path">
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是当我在 LinkedIn 上分享我的链接时,LinkedIn 不会在链接预览中获取描述。
相同的链接在 Facebook 上运行良好,因为 Facebook 也支持开放图元标签。
我错过了什么吗?
是否有任何类型的描述验证?
我正在使用 socket.io 在 AWS Fargate 中运行套接字服务器容器
连接用户数在 800-1000 左右时一切正常,但是当客户端数量增加时,旧套接字连接会自动断开并出现错误transport error
。
我的 AWS ECS 服务(Fargate 容器)在 AWS 应用程序负载均衡器后面运行。
需要应用任何特定配置来支持与我的容器的数千个并发连接吗?
连接到单个套接字服务器的并发用户数是否有限制?
AWS任务定义有4GB内存和2个CPU
套接字服务器代码:
io = module.exports = require('socket.io')(server, {
'pingInterval': 10000,
'pingTimeout': 7000,
'origins': (env.APPLY_ALLOW_ORIGIN_FILTER) ? env.SOCKET_WHITELIST_URL : '*:*',
transports: ['websocket', 'htmlfile', 'xhr-polling', 'jsonp-polling', 'polling']
})
Run Code Online (Sandbox Code Playgroud) 我在使用consul作为服务发现的微服务设置中将spring cloud网关用作API网关。
在某些情况下,某些微服务的API需要2分钟以上的时间,网关会抛出以下错误:
java.io.IOException: Connection closed prematurely
at reactor.ipc.netty.http.client.HttpClientOperations.onInboundClose(HttpClientOperations.java:269)
at reactor.ipc.netty.channel.ChannelOperationsHandler.channelInactive(ChannelOperationsHandler.java:113)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelInactive(CombinedChannelDuplexHandler.java:420)
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377)
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342)
at io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:282)
at io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:223)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1429)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:947)
at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:313)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
我多次尝试了相同的API,恰好在2分钟后收到此错误。
是否有任何属性设置。版本和依赖项详细信息:
compile('org.springframework.cloud:spring-cloud-starter-consul-discovery')
compile('org.springframework.cloud:spring-cloud-starter-gateway')
compile('org.springframework.cloud:spring-cloud-starter-openfeign')
springBootVersion=2.0.3.RELEASE
springDMPVersion=1.0.4.RELEASE
springPlatformBomVersion=Cairo-SR2
Run Code Online (Sandbox Code Playgroud)
功能区设置:
ribbon:
ConnectTimeout: 3000
ReadTimeout: 3000
Run Code Online (Sandbox Code Playgroud) java spring-boot spring-cloud netflix-ribbon spring-cloud-gateway
我已将 Azure Active Directory 注册为 Keycloack 服务器中的身份提供程序。我在 azure 的 id_token 中获取组数组,它看起来像:
{
aud: "https://contoso.onmicrosoft.com/scratchservice",
iss: "https://sts.windows.net/b9411234-09af-49c2-b0c3-653adc1f376e/",
iat: 1416968588,
nbf: 1416968588,
exp: 1416972488,
ver: "1.0",
tid: "b9411234-09af-49c2-b0c3-653adc1f376e",
amr: [
"pwd"
],
roles: [
"Admin"
],
oid: "6526e123-0ff9-4fec-ae64-a8d5a77cf287",
upn: "[hidden email]",
unique_name: "[hidden email]",
sub: "yf8C5e_VRkR1egGxJSDt5_olDFay6L5ilBA81hZhQEI",
family_name: "User",
given_name: "Sample",
groups: [
"0e129f6b-6b0a-4944-982d-f776000632af",
"323b13b3-1851-4b94-947f-9a4dacb595f4",
"6e32c250-9b0a-4491-b429-6c60d2ca9a42",
"f3a161a7-9a58-4e8f-9d47-b70022a07424",
"8d4c81b2-b1ad-476d-9574-544d155aa6ff",
"1bf80164-ff24-4866-b19c-6212e5b9a847",
"76f80127-f2cd-46f4-8c52-8edd8bc749b1",
"0ba27160-44d0-42b5-b90c-47b3fcc48e35"
],
appid: "b075ddef-0efa-123b-997b-de1337c29185",
appidacr: "1",
scp: "user_impersonation",
acr: "1"
}
Run Code Online (Sandbox Code Playgroud)
在Keycloak服务器生成的id_token中,没有组。如何在 keycloack id_token 中获取 azure AD 组。
我使用tomcat7作为应用程序服务器运行我的java Web应用程序(.war)当我重新启动tomcat时需要20-25分钟来部署可能的战争文件.我重启tomcat时得到这个日志:
Sep 24, 2016 9:45:29 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 24, 2016 9:45:29 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.68 (Ubuntu)
Sep 24, 2016 9:45:29 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/tnu.war
Sep 24, 2016 9:45:30 AM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/tnu/WEB-INF/lib/javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Sep 24, 2016 9:45:33 AM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained …
Run Code Online (Sandbox Code Playgroud) 我正在将 Spring Boot Web 应用程序作为 docker 服务运行,并且无需运行状况检查即可正常运行。
但是,当我尝试创建具有运行状况检查选项的 docker 服务时,我的服务会在一段时间后(可能在运行状况检查超时之后)自动重新启动,并且它永远不会稳定。
我创建\health
休息端点并简单地返回 ok 这是我用来创建带有运行状况检查选项和不带运行状况检查选项的服务的命令。
带有健康检查选项的命令:
sudo docker service create \
--health-cmd="curl --silent --fail localhost:8090/health || exit 1" \
--health-interval=5s \
--health-retries=12 \
--health-timeout=2s \
--health-start-period=60s \
--name=my-service \
-p "8090:8090" \
my-docker-img
Run Code Online (Sandbox Code Playgroud)
输出:
s43fbah1qdlxb01s4x5veecos
overall progress: 0 out of 1 tasks
1/1: starting [============================================> ]
Run Code Online (Sandbox Code Playgroud)
没有健康检查的命令:
sudo docker service create \
--name=my-service \
-p "8090:8090" \
my-docker-img
Run Code Online (Sandbox Code Playgroud)
我的 Spring Boot 应用程序需要 20 秒才能启动并运行。
我正在使用 PDFBox 来确定 pdf 文件是否受密码保护。这是我的代码:
boolean isProtected = pdfDocument.isEncrypted();
Run Code Online (Sandbox Code Playgroud)
我的文件属性在截图中。在这里,我isProtected= true
什至不需要密码就可以打开它。
注意:该文件有文档打开密码:否和权限密码:是。