Nginx-上游重定向不工作
希望有人能指出我的配置失败 我有一个问题,我的上游重定向不能正常工作(必须是配置问题),它从https重定向到http,而我目前没有运行它。显然,我要求我的https服务器只提供安全通信,而不重定向到http 这是我在浏览器栏中收到的信息: 但我要求它通过https上传到上游 在浏览器的调试中,我看到: 获取网络::错误连接被拒绝 无法理解它为什么会碰到端口80。 我已经在端口80上关闭了http,因为我需要https工作。 我希望有人能帮我,让我发疯 谢谢你的关注 这是端口443的当前配置Nginx-上游重定向不工作,nginx,syntax,Nginx,Syntax,希望有人能指出我的配置失败 我有一个问题,我的上游重定向不能正常工作(必须是配置问题),它从https重定向到http,而我目前没有运行它。显然,我要求我的https服务器只提供安全通信,而不重定向到http 这是我在浏览器栏中收到的信息: 但我要求它通过https上传到上游 在浏览器的调试中,我看到: 获取网络::错误连接被拒绝 无法理解它为什么会碰到端口80。 我已经在端口80上关闭了http,因为我需要https工作。 我希望有人能帮我,让我发疯 谢谢你的关注 这是端口443的当前配置
upstream HttpsMainWorker {
# Sticky session
ip_hash;
server 10.1.161.59:8080;
server 10.1.161.56:8080;
}
upstream HttpsReportWorker {
# Sticky session
ip_hash;
server 10.1.161.64:8080;
}
upstream HttpsApiWorker {
# Sticky session
ip_hash;
server 10.1.161.51:8080;
}
server {
listen 443 ssl;
server_name nginx.dev1.whispir.net;
keepalive_timeout 70;
ssl on;
ssl_certificate /etc/nginx/certs/2016/61d2d567aece769c.crt;
ssl_certificate_key /etc/nginx/certs/2016/wildcard.dev1.whispir.netclear.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/app17web/access.log main;
error_log /var/log/nginx/app17web/error.log debug;
root /data/htdocs/app17web.dev1.whispir.net;
index index.jsp;
rewrite_log on;
location ~* \.(?:ico|css|js|gif|jpe?g|png|pdf)$ {
expires 1d;
add_header Pragma public;
add_header Cache-Control "public";
}
error_page 401 /401.html;
error_page 403 /403.html;
error_page 500 502 /500.html;
error_page 503 /503.html;
error_page 400 404 /404.html;
location = /404.html {
internal;
}
error_page 500 502 503 /50x.html;
location = /50x.html {
root html;
}
location /{
try_files $uri @backend;
}
location @backend {
proxy_pass http://HttpsMainWorker;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~ \.jsp$ {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /ivr/ivrRequest.ivr {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /app/cfu/* {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /tmpl/* {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
最有可能的是上游应用程序(在端口8080上运行)正在发出重定向。需要将其配置为在重定向中使用
https
,或者需要通知其前端连接通过https
到达
您的配置为此目的插入一个标题X-Forwarded-Proto
,但仅针对其中一个位置
proxy\u set\u header
指令从外部块继承,仅当位置中未设置其他proxy\u set\u header
指令时
因此,要么添加一个proxy\u set\u头X-Forwarded-Proto$方案将code>语句放入每个受影响的位置
块中,或将代理集头
指令的所有
移动到服务器
块范围中
例如:
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location @backend {
proxy_pass http://HttpsMainWorker;
}
location ~ \.jsp$ {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /ivr/ivrRequest.ivr {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /app/cfu/* {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /tmpl/* {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
有关详细信息,请参阅。最有可能的是上游应用程序(在端口8080上运行)正在发出重定向。需要将其配置为在重定向中使用
https
,或者需要通知其前端连接通过https
到达
您的配置为此目的插入一个标题X-Forwarded-Proto
,但仅针对其中一个位置
proxy\u set\u header
指令从外部块继承,仅当位置中未设置其他proxy\u set\u header
指令时
因此,要么添加一个proxy\u set\u头X-Forwarded-Proto$方案将code>语句放入每个受影响的位置
块中,或将代理集头
指令的所有
移动到服务器
块范围中
例如:
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location @backend {
proxy_pass http://HttpsMainWorker;
}
location ~ \.jsp$ {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /ivr/ivrRequest.ivr {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /app/cfu/* {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
location /tmpl/* {
proxy_pass http://HttpsMainWorker;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 5s;
}
详情请参见。嗨,Richard,感谢您的快速响应,它非常有效,非常感谢。非常感谢。嗨,Richard,谢谢你的快速反应,它很有魅力,真的很感激。非常感谢。