reverseproxy_ynh/conf/nginx.conf
2024-08-24 23:13:14 +02:00

40 lines
1.2 KiB
Nginx Configuration File

location @{{ name }}--proxy {
proxy_pass {{ proxy_path }};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Port $server_port;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
more_clear_input_headers 'Accept-Encoding';
}
location = {{ path }} {
return 302 {{ path }};
}
location {{ path }}/ {
{% if assets_path %}
alias {{ assets_path }};
{% endif %}
# This is a reverse-proxy, not a basic HTML site
# We do not wish to enable autoindex in general, and will
# not try_files uri/ for this reason.
#
# But if no assets_path is defined, try the backend directly.
#
# Note: We could include an app setting for autoindex some time.
# But try_files uri/ without autoindex will result in 403.
{% if assets_path %}
try_files $uri @{{ name }}--proxy =@404;
{% else %}
try_files ${{ name }}--proxy =@404;
{% endif %}
}