server { listen 80; #listen 443 ssl http2; # 域名 server_name localhost 192.168.10.86 wanggang.com www.wanggang.com; #ssl_certificate /etc/nginx/cert/domain.com.crt; #ssl_certificate_key /etc/nginx/cert/domain.com.key; #include /etc/nginx/cert/options-ssl-nginx.conf; index index.html index.htm index.php default.html default.htm default.php; root /wwwroot; # 跳转到首选域名,若是带www的,请自行加上www #if ($host != wanggang.com) { # rewrite ^(.*)$ $scheme://wanggang.com$1 permanent; #} # https 301跳转,不需要轻删除 #if ($scheme = http) { # rewrite ^(.*)$ https://$host$1 permanent; #} location ~ [^/]\.php(/|$) { include /etc/nginx/conf.d/ext/header.conf; fastcgi_pass unix:/dev/shm/php-cgi.sock; #fastcgi_pass php-fpm:9000; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; include fastcgi.conf; } location ~* .*\.(gif|jpg|jpeg|png|bmp|jepg|css|js|ico|ogg|ogv|svg|svgz|eot|otf|woff|woff2|mp4|ttf|rss|atom|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires 30d; } # 解决 robots漏洞 location = /robots.txt { if ($http_user_agent !~* "spider|bot|Python-urllib|pycurl") { return 403; } #access_log off; log_not_found off; } location ~ /\. { deny all; #access_log off; log_not_found off; } access_log /data/log/$host.log; }