我设置我的nginx服务器尽可能高效。从登录页面开始。我决定使用gzip_static指令并且效果很好,将我的14kb index.html预压缩为3kb,并在调用site.com/index.html时将其提供。
但问题是,当调用site.com/ nginx返回403时(我已将其设置为始终返回403以防止扫描程序试图找到他们不应该写的内容,因此这基本上是404.)
默认情况下,如何获取位置/提供预压缩的index.html?
server {
server_name mxgaming.com;
return 301 $scheme://www.mxgaming.com$request_uri;
}
server {
listen 80;
#listen 443 ssl;
server_name www.mxgaming.com;
root C:\\WebServer\\nginx\\www\\www.mxgaming.com;
index index.html index.htm index.php;
charset utf-8;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log C:\\WebServer\\nginx\\logs\\www.mxgaming.com-error.log error;
sendfile off;
client_max_body_size 100m;
gzip_static on;
gzip off;
gzip_min_length 1024;
gzip_proxied any;
gzip_http_version 1.1;
gzip_comp_level 4;
gzip_vary on;
gzip_types text/xml text/javascript application/atom+xml application/javascript application/json application/rss+xml application/xml+rss application/vnd.ms-fontobject application/x-font-ttf application/x-web-app- manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component;
server_tokens off;
location / {
try_files $uri $uri/ /index.html;
}
location ~* /teamspeak/? {
try_files $uri $uri/ /teamspeak.html;
}
location /teamspeakfull(?:/|) {
try_files $uri $uri/ /teamspeakfull.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors off;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 60;
fastcgi_read_timeout 60;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|woff|ogv|webm|htc)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(css|js)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
try_files $uri $uri/ /assets/$1/$uri;
}
location ~ /\.ht {
deny all;
}
}
再次,Calling和.html,.js .css只要你直接调用它们就可以工作,但只是/不是。