我在主机上有一个Nginx,在Docker
容器中有一个Rancher服务器。我想使用Nginx
反向代理Rancher:
这是我的Nginx配置:
map $http_upgrade $connection_upgrade {
default Upgrade;
'' close;
}
location /rancher {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
但是当我尝试访问https://mydomain/rancher
时,无法加载静态文件。我想知道:
Nginx
代理后面运行Rancher服务器是否常见?答案 0 :(得分:1)
我猜您想要通过TLS访问您的应用程序。请尝试以下配置,
server {
listen 443 default_server;
server_name mydomain;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location /rancher {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}