问题描述
|
将Nginx配置为Play前面的反向代理!并传递https
设置以下标头:-
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl https;
login()
[https://localhost/login
]正在转发给Play!在港口
9000为\'http \'。但是login()中的request.secure仍然为'false \'。任何想法 ?
更新:
这是服务器配置:
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /home/aymer/play/key/localhost.crt;
ssl_certificate_key /home/aymer/play/key/localhost.key;
ssl_session_timeout 5m;
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /home/aymer/play/playapp/public;
expires 30d;
}
location ~* (login|register)$ {
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl on;
}
location / {
rewrite ^/(.*) http://$host/$1 permanent;
}
}
解决方法
第二个条目是错误的,应该是:
proxy_set_header X-Forwarded-Ssl on;
那将解决问题
更新:无法测试,我唯一缺少的是此标头:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
除此之外,一切似乎都是正确的。
, 只是为了弄清楚。我遇到了这个问题,要获得完整的工作解决方案有些困难。
为了使其工作,您的nginx配置必须包含:
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
参数
proxy_set_header X-Forwarded-Proto https;
是没有用的(对于此用例)。
但是您还需要在application.conf中指定它:
XForwardedSupport=<proxy server address> # generally,127.0.0.1
这个答案只是Pere Villega和Aymer之间整个对话的回顾。
, 我想解决方案将是改变:
\"proxy_redirect off;\"
进入
\"proxy_redirect http://localhost https://localhost;\"
“ 11”是server_name的值。