diff --git a/templates/etc/nginx/sites-available/movim.j2 b/templates/etc/nginx/sites-available/movim.j2 new file mode 100644 index 0000000..0680a6f --- /dev/null +++ b/templates/etc/nginx/sites-available/movim.j2 @@ -0,0 +1,81 @@ + +{% if item.pic_cache is defined and item.pic_cache == 'true' %} +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"; +{% endif %} +{% extends "core.j2" %} + +{% block root %} + root {{ nginx_www_dir }}{{ item.root }}; + index index.php; +{% 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 / { + set $no_cache 1; + try_files $uri $uri/ /index.php$is_args$args; + } +{% endif %} + + location ~ /\. { + deny all; + } + + location = /favicon.ico { + expires 30d; + access_log off; + log_not_found off; + } + + location ~ ^/(config|temp|log)/ { + deny all; + } + + location ~ \.php$ { + fastcgi_pass {{ item.fastcgi_pass }}; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + add_header X-Cache $upstream_cache_status; + fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie"; + fastcgi_cache nginx_cache; + fastcgi_cache_valid any 7d; + fastcgi_cache_bypass $no_cache; + fastcgi_no_cache $no_cache; + } + +{% if item.ws is defined and item.ws == 'true' %} + location /ws/ { + proxy_pass {{ item.upstream_schema }}://{{ item.upstream_name }}:{{ item.upstream_port }}; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_redirect off; + } +{% endif %} +{% if item.pic_cache is defined and item.pic_cache == 'true' %} + location /picture { + set $no_cache 0; + try_files $uri $uri/ /index.php$is_args$args; + } +{% endif %} + +{% endblock %}