fix issues + set possibility to deploy as proxy

This commit is contained in:
meaz 2023-06-26 14:21:03 +02:00
parent 6f47977d5b
commit 8c92725182
Signed by: meaz
GPG Key ID: CD7A47B2F1ED43B4
1 changed files with 33 additions and 7 deletions

View File

@ -1,15 +1,41 @@
fastcgi_cache_path /tmp/nginx_cache levels=1:2 keys_zone=nginx_cache:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
#map $http_upgrade $connection_upgrade {
# default upgrade;
# '' close;
# }
{% extends "core.j2" %}
{% block root %}
root {{ nginx_www_dir }}{{ item.root }};
index {{ item.index }};
{% endblock %}
{% block location %}
## LOCATIONS
{% if item.proxy == 'true' %}
location / {
proxy_pass {{ item.proto }}://{{ item.upstream_name }}:{{ item.listen }};
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
}
{% else %}
location / {
index index.php;
add_header Access-Control-Allow-Origin *;
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?query=$1 last;
}
}
{% endif %}
location ~ /\. {
deny all;
}
@ -20,10 +46,10 @@ fastcgi_cache_key "$scheme$request_method$host$request_uri";
log_not_found off;
}
location ~* \.(txt|js|css|png|jpe?g|gif|ico|svg)$ {
expires 30d;
log_not_found off;
}
# location ~* \.(txt|js|css|png|jpe?g|gif|ico|svg)$ {
# expires 30d;
# log_not_found off;
# }
location ~ ^/(README.md|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
deny all;
@ -39,9 +65,9 @@ fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /ws/ {
proxy_pass {{ item.upstream_schema }}://{{ item.upstream }}:{{ item.upstream_port }};
proxy_pass {{ item.upstream_proto }}://{{ item.upstream_name }}:{{ item.upstream_port }};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";