1、简洁配置
server { listen 80; server_name www.test.com test.com *.test.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name www.test.com test.com; ssl_certificate /usr/local/nginx/ssl/xzw.crt; ssl_certificate_key /usr/local/nginx/ssl/xzw.key.unsecure; location / { index index.html index.php; root /data/starcor/www; } }
2、线上配置
include ng_http_lua.conf; server { listen 57817; listen 80; index index.php; root /data/starcor/www; access_log /data/logs/access_log.log common; include ng_static_lua.conf; location ~ ^\/nn_cms\/data\/(.*)\.php? { if ($uri !~ ^\/nn_cms\/data\/(template|webapp)\/) { return 404; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ .*\.php?$ { include fcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/starcor/www$fastcgi_script_name; } location ~ /php-fpm-status$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /data/starcor/www$fastcgi_script_name; access_log off; allow 127.0.0.1; deny all; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } } ###HTTPS配置 server { #证书配置 listen 443; #server_name xjdxmobilxcx.starcor.com; ssl on; ssl_certificate /etc/ssl/crt/server.cer; ssl_certificate_key /etc/ssl/crt/server.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE"; ssl_prefer_server_ciphers on; location / { index index.php; root /data/starcor/www; } include ng_static_lua.conf; #PHP解析 location ~ .*\.php?$ { #root /data/starcor/www; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/starcor/www/$fastcgi_script_name; } }