1,如果想配置一個功能變數名稱到指定目錄咋弄呢?下麵這個 2,如果想讓這個功能變數名稱同時也支持https訪問,該咋辦呢?下麵這個server和上面的server同時在就好了 3,如果想讓同個ip,支持兩個https功能變數名稱,該咋辦呢?把上面server複製一份,把裡面的server_name 換成另一個功能變數名稱,並且把證 ...
1,如果想配置一個功能變數名稱到指定目錄咋弄呢?下麵這個
server { listen 80; server_name 這裡換成你的功能變數名稱,例如baidu.com; set $root_path '/home/wwwroot/tapai_html/'; root $root_path; index index.html index.php index.htm; # rewrite ^(.*) https://$server_name; try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index /index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # location /imgtext_detail { # proxy_pass /home/wwwroot/tapai_html/imgtext_detail; # proxy_pass http://127.0.0.1:9000/imgtext_detail/; # } location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { root $root_path; } location ~ /\.ht { deny all; } }
2,如果想讓這個功能變數名稱同時也支持https訪問,該咋辦呢?下麵這個server和上面的server同時在就好了
server { listen 443; listen [::]:443; server_name 這裡換成你的功能變數名稱,例如baidu.com; root /home/wwwroot/tapai_html/; ssl on; # ssl_session_tickets off; ssl_certificate "/etc/nginx/ssl/這裡換成證書.crt"; #也有可能是.pem結尾的 ssl_certificate_key "/etc/nginx/ssl/這裡換成秘鑰.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
3,如果想讓同個ip,支持兩個https功能變數名稱,該咋辦呢?把上面server複製一份,把裡面的server_name 換成另一個功能變數名稱,並且把證書和秘鑰路徑改一下就行了
server { listen 443; listen [::]:443; server_name 這裡配置另一個功能變數名稱,比如qq.com; root /home/wwwroot/tapai_html/; ssl on; # ssl_session_tickets off; ssl_certificate "/etc/nginx/ssl/這裡換成此功能變數名稱對應的證書.pem"; ssl_certificate_key "/etc/nginx/ssl/這裡換成此功能變數名稱對應的秘鑰.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }