nginx as reverse proxy: X-Forwarded-Proto not working
- Dominant language
- Shell
- Stars
- 769
- Forks
- 168
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm having the following setup:
1. Synology NAS, acting as a reverse proxy.
2. Server running wallabag and nginx inside containers.
The NAS forwards HTTPS requests to my server as HTTP requests. The nginx container should forward the HTTP requests to the wallabag container.
This is my nginx configuration:
```
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://wallabag;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
```
I can access the login page from my browser via `https://example.com/login`, however, when I enter the credentials and press "Login", a POST is made to `https://example.com/login_check`, which results in a redirect to `http://example.com` instead of `https://example.com`. It looks like the `X-Forwarded-Proto` header is ignored...
This is the response:
```
HTTP/1.1 302 Found
Cache-Control: private, must-revalidate
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Sat, 24 Mar 2018 20:30:41 GMT
expires: -1
Keep-Alive: timeout=20
Location: http://holmes.matthjes.de/
pragma: no-cache
Server: nginx
Set-Cookie: PHPSESSID=f73b856e467ac7c31e855a749c4c4544; path=/; HttpOnly
Set-Cookie: REMEMBERME=V2FsbGFiYWdcVXNlckJ1bmRsZVxFbnRpdHlcVXNlcjpkMkZzYkdGaVlXYz06MTU1MzQ1OTQ0MTpiOGEyNDg3MDIzYzllOTQ5ZjliYjljMDFmNGYzNzEyY2FkMTllYzAzZjk3YzFlODE5OWM1ZWFjNjU3NmZlYzk2; expires=Sun, 24-Mar-2019 20:30:41 GMT; Max-Age=31536000; path=/; HttpOnly
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Powered-By: PHP/7.1.15
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.