123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- server {
- listen 80;
- server_name x9169e.xyz;
- root /web/online/x9169e_xyz;
- index index.html index.htm;
- # 重定向到HTTPS并带"www"的域名
- if ($host != "x9169e.xyz") {
- return 301 https://x9169e.xyz$request_uri;
- }
- location / {
- root /web/online/x9169e_xyz;
- index index.php index.html index.htm;
- if (!-e $request_filename) {
- rewrite ^(.*)$ /index.php/$1 last; #注(目的是将/后面的路径前加上index.php)
- }
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ {
- #禁止缓存,每次都从服务器请求
- expires 1d;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ {
- #禁止缓存,每次都从服务器请求
- expires 1d;
- }
- location ~ \.php$ {
- root /web/online/x9169e_xyz;
- fastcgi_split_path_info ^(.+\.php)(.*)$;
- fastcgi_pass 127.0.0.1:9000;
- #包含nginx服务器传递给fastcgi程序的参数,php中通过$_SERVER['参数名']可获取
- include fastcgi.conf;
- set $path_info "";
- set $fastcgi_script_name_new $fastcgi_script_name;
- #判断url是否是pathinfo形式的,如果是则把这个url分割成两部分,index.php入口文件之后的pathinfo部分存入$path_info变量中,剩下的部分和$document_root根目录定位index.php入口文件在文件系统中的绝对路径 .
- if ($fastcgi_script_name ~* "^(.+\.php)(/.+)$" ) {
- set $fastcgi_script_name_new $1;
- set $path_info $2;
- }
- #对fastcgi.conf中的SCRIPT_FILENAME和SCRIPT_NAME fastcgi参数进行重写,目的是指定入口文件在文件系统中的绝对路径给script_filename参数,让fastcgi知道index.php文件位置。
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name_new;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name_new;
- #定义一个新的nginx服务器传递给fastcgi的参数PATH_INFO,thinkphp需要这个入口文件index.php后的pathinfo信息
- fastcgi_param PATH_INFO $path_info;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /web/online/x9169e_xyz;
- }
- }
- server {
- listen 443 ssl;
- #配置HTTPS的默认访问端口为443。
- #如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
- #如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。
- server_name x9169e.xyz;
- root /web/online/x9169e_xyz;
- index index.html index.htm;
- ssl_certificate /etc/nginx/ssl/x9169e_xyz/START_x9169e_xyz.pem;
- ssl_certificate_key /etc/nginx/ssl/x9169e_xyz/START_x9169e_xyz.key;
- ssl_session_timeout 5m;
- ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
- #表示使用的加密套件的类型。
- ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; #表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
- ssl_prefer_server_ciphers on;
- if ($host != "x9169e.xyz") {
- return 301 https://x9169e.xyz$request_uri;
- }
- location / {
- root /web/online/x9169e_xyz;
- index index.php index.html index.htm;
- if (!-e $request_filename){
- rewrite ^(.*)$ /index.php?s=$1 last;
- break;
- }
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ {
- #禁止缓存,每次都从服务器请求
- expires 1d;
- }
- location ~ \.php$ {
- root /web/online/x9169e_xyz;
- fastcgi_split_path_info ^(.+\.php)(.*)$;
- fastcgi_pass 127.0.0.1:9000;
- #包含nginx服务器传递给fastcgi程序的参数,php中通过$_SERVER['参数名']可获取
- include fastcgi.conf;
- set $path_info "";
- set $fastcgi_script_name_new $fastcgi_script_name;
- #判断url是否是pathinfo形式的,如果是则把这个url分割成两部分,index.php入口文件之后的pathinfo部分存入$path_info变量中,剩下的部分和$document_root根目录定位index.php入口文件在文件系统中的绝对路径 .
- if ($fastcgi_script_name ~* "^(.+\.php)(/.+)$" ) {
- set $fastcgi_script_name_new $1;
- set $path_info $2;
- }
- #对fastcgi.conf中的SCRIPT_FILENAME和SCRIPT_NAME fastcgi参数进行重写,目的是指定入口文件在文件系统中的绝对路径给script_filename参数,让fastcgi知道index.php文件位置。
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name_new;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name_new;
- #定义一个新的nginx服务器传递给fastcgi的参数PATH_INFO,thinkphp需要这个入口文件index.php后的pathinfo信息
- fastcgi_param PATH_INFO $path_info;
- }
- }
|