mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-03-03 16:00:29 +01:00
Allow http/https with custom port (@met67)
https://github.com/alexbelgium/hassio-addons/issues/345
This commit is contained in:
@@ -5,20 +5,30 @@ server {
|
||||
client_max_body_size 0;
|
||||
|
||||
location / {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
|
||||
# Base from https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#nginx
|
||||
proxy_bind $server_addr;
|
||||
proxy_pass http://127.0.0.1:8083;
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 30;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_bind $server_addr;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
proxy_set_header X-Script-Name %%UIPATH%%; # IMPORTANT: path has NO trailing slash
|
||||
#proxy_set_header HA-Calibre-User admin;
|
||||
proxy_redirect http://$host/ $scheme://$host:%%haport%%/;
|
||||
proxy_redirect $scheme://$host/ $scheme://$host:%%haport%%/;
|
||||
|
||||
# Optimisation
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 30;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
|
||||
# Ensure work with both http and https (code by @met67)
|
||||
if ($http_referer ~* "^(http[s]?)://([^:]+):(\d*)(/.*)$") {
|
||||
set $x_scheme $1;
|
||||
set $x_host $2;
|
||||
set $x_port $3;
|
||||
}
|
||||
|
||||
proxy_set_header X-Scheme $x_scheme;
|
||||
proxy_redirect http://$host/ $x_scheme://$x_host:$x_port/;
|
||||
proxy_redirect https://$host/ $x_scheme://$x_host:$x_port/;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user