Skip to content

Commit e65f1db

Browse files
committed
Only set X-Forwarded-Proto when header not set
When the seafile docker container is behind a proxy that does the TLS termination, such that the seafile docker sees HTTP only, then, it receives requests where the following headers are set in the following way: X-Forwarded-Proto: https X-Forwarded-Ssl: on Because the default NGINX template has this directive: proxy_set_header X-Forwarded-Proto $scheme the request gets transmitted to gunicorn with the following, contradictory values: X-Forwarded-Proto: http X-Forwarded-Ssl: on Thus Seafile rejects the requests with a "Contradictory scheme headers" error. We instead change the header only when it is not set. Fixes #226.
1 parent 833d5be commit e65f1db

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

templates/seafile.nginx.conf.template

+7-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ server {
4545
proxy_set_header Host $http_host;
4646
proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
4747
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
48-
proxy_set_header X-Forwarded-Proto $scheme;
48+
proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
4949
proxy_set_header X-Real-IP $remote_addr;
5050
proxy_set_header Connection "";
5151
proxy_http_version 1.1;
@@ -88,7 +88,7 @@ server {
8888
proxy_set_header X-Real-IP $remote_addr;
8989
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
9090
proxy_set_header X-Forwarded-Host $server_name;
91-
proxy_set_header X-Forwarded-Proto $scheme;
91+
proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
9292
proxy_read_timeout 1200s;
9393
client_max_body_size 0;
9494

@@ -108,3 +108,8 @@ server {
108108
}
109109
{% endif -%}
110110
}
111+
112+
map $http_x_forwarded_proto $x_forwarded_proto {
113+
"" $scheme;
114+
default $http_x_forwarded_proto;
115+
}

0 commit comments

Comments
 (0)