我有下面的Docker设置:
我的问题是,当访问网站时,504错误会被抛出。我将环境变量提供给包含多个WildFly、LETSENCRYPT_HOST和LETSENCRYPT_EMAIL的VIRTUAL_HOST容器。我试着暴露港口,但没有帮助。端口8080在docker ps -a
中显示。重量,max_fails等是我在网上发现的一个教程中的,因为它对我不起作用,我认为它能解决这个问题。使用curl :8080给出了成功的响应。
我在容器中的Nginx配置:
# wildfly.example.com
upstream wildfly.example.com {
# Cannot connect to network of this container
server 172.17.0.5:8080 weight=100 max_fails=5 fail_timeout=5;
}
server {
server_name wildfly.example.com;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
# Do not HTTPS redirect Let'sEncrypt ACME challenge
location /.well-known/acme-challenge/ {
auth_basic off;
allow all;
root /usr/share/nginx/html;
try_files $uri =404;
break;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
server_name wildfly.example.com;
listen 443 ssl http2 ;
access_log /var/log/nginx/access.log vhost;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_certificate /etc/nginx/certs/wildfly.example.com.crt;
ssl_certificate_key /etc/nginx/certs/wildfly.example.com.key;
ssl_dhparam /etc/nginx/certs/wildfly.example.com.dhparam.pem;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/nginx/certs/wildfly.example.com.chain.pem;
add_header Strict-Transport-Security "max-age=31536000" always;
include /etc/nginx/vhost.d/default;
location / {
proxy_pass http://wildfly.example.com;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $server_addr:$server_port;
proxy_set_header X-Real-IP $remote_addr;
}
}
无法连接到网络的注释存在,因为它没有自动检测到服务器,而我不得不手动编辑内部IP。我的docker logs nginxcontainerid
输出:
2020/06/04 14:14:37 [error] 22247#22247: *6228 upstream timed out (110: Connection timed out) while connecting to upstream, client: IPHERE, server: wildfly.example.com, request: "GET / HTTP/2.0", upstream: "http://172.17.0.5:8080/", host: "wildfly.example.com"
发布于 2020-06-05 12:50:06
我不熟悉WildFly,但是该应用程序会接受带有wildlfy.example.com头的请求吗?您是带有IP的容器上的CURLing :8080,可能需要设置WildFly服务器来接受来自域本身的请求。504错误通常是服务器由于配置错误或无法访问而简单地删除请求,这是基于您的CURL。我会在您的WildFly容器中查找问题。
https://serverfault.com/questions/1020156
复制相似问题