diff --git a/nginx.dist.conf b/nginx.dist.conf index 44462da26b5a361d39232a982e55fe5c6576d5af..ab42a436ae29f3f2aad64f1ef858a6dfe9de384b 100644 --- a/nginx.dist.conf +++ b/nginx.dist.conf @@ -7,6 +7,7 @@ server { root "/www/forkbb/public"; # you need to set your values autoindex off; charset utf-8; + server_tokens off; location = /favicon.ico { access_log off; @@ -20,32 +21,70 @@ server { log_not_found off; } - location ~ ^/(js|img|style)/(.+)\.v\.[0-9]+\.([^.\\/]++)$ { - try_files /$1/$2.$3 =404; + location / { + fastcgi_hide_header X-Powered-By; + fastcgi_index index.dist.php; - expires 1y; + include fastcgi_params; + fastcgi_param HTTP_PROXY ""; + #fastcgi_param SCRIPT_FILENAME $document_root/index.dist.php; + fastcgi_param SCRIPT_FILENAME $realpath_root/index.dist.php; + fastcgi_param DOCUMENT_ROOT $realpath_root; + + fastcgi_pass unix:/var/run/php-fpm.sock; # you need to set your values } - location ~ ^/(js|img|style)/ { - try_files $uri =404; + location /js/ { + location ~ ^(.+)\.v\.[0-9]+\.([^.\\/]++)$ { + try_files $1.$2 =404; + + expires 1y; + } + + location ~ /\.ht { + return 404; + } + + location ~ \.(css|js|gif|png|jpg|jpeg|webp)$ { + try_files $uri =404; + + expires 1y; + } } - location ~ /\.ht { - deny all; + location /img/ { + location ~ ^(.+)\.v\.[0-9]+\.([^.\\/]++)$ { + try_files $1.$2 =404; - access_log off; - log_not_found off; + expires 1y; + } + + location ~ /\.ht { + return 404; + } + + location ~ \.(css|js|gif|png|jpg|jpeg|webp)$ { + try_files $uri =404; + + expires 1y; + } } - location / { - fastcgi_index index.dist.php; + location /style/ { + location ~ ^(.+)\.v\.[0-9]+\.([^.\\/]++)$ { + try_files $1.$2 =404; - include fastcgi_params; - fastcgi_param HTTP_PROXY ""; - #fastcgi_param SCRIPT_FILENAME $document_root/index.dist.php; - fastcgi_param SCRIPT_FILENAME $realpath_root/index.dist.php; - fastcgi_param DOCUMENT_ROOT $realpath_root; + expires 1y; + } + + location ~ /\.ht { + return 404; + } + + location ~ \.(css|js|gif|png|jpg|jpeg|webp)$ { + try_files $uri =404; - fastcgi_pass unix:/var/run/php-fpm.sock; # you need to set your values + expires 1y; + } } }