From 25da82adad3ee22e21b4fa3d18d21fee2018892f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 28 Sep 2021 13:23:43 +0200 Subject: [PATCH] Update nginx.conf --- conf/nginx.conf | 84 +++++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 59 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index ef2e8b0..f09671a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,70 +1,36 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - alias __FINALPATH__/ ; - index index.php; + # Path to source + alias __FINALPATH__/ ; - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } - client_max_body_size 30m; + index index.php; - try_files $uri $uri/ __PATH__/index.php?q=$uri&$args; + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file + #client_max_body_size 50M; - # Old image system ? - rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last; - rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last; - rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last; - rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last; - rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last; + try_files $uri $uri/ index.php; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - error_page 404 /index.php?controller=404; + #fastcgi_index index.php; + include fastcgi_params; - # Deny access to .htaccess .DS_Store .htpasswd etc - location ~ /\. { - deny all; - } + include /etc/nginx/fastcgi_params; + fastcgi_intercept_errors on; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + + #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } - # Deny access file theme - location ~ \.tpl { - deny all; - } - - location ~* \.(css|js|docx|zip|pptx|swf|txt|jpg|jpeg|png|gif|swf|webp|flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac)$ { - expires max; - log_not_found off; - more_set_headers "Pragma: public"; - more_set_headers "Cache-Control: public; must-revalidate; proxy-revalidate"; - } - - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; - - fastcgi_keep_conn on; - fastcgi_intercept_errors on; - fastcgi_max_temp_file_size 0; - fastcgi_temp_file_write_size 256k; - fastcgi_buffer_size 8k; - fastcgi_buffers 64 8k; - fastcgi_busy_buffers_size 8k; - fastcgi_connect_timeout 300; - fastcgi_read_timeout 300; - fastcgi_send_timeout 300; - client_max_body_size 30m; - } - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; }