本文共 2394 字,大约阅读时间需要 7 分钟。
Ⅱ. 修改Nginx配置文件
打开/usr/local/nginx/conf/nginx.conf文件,添加以下配置:服务器块配置(正式环境):
server { listen 80; server_name xxx.com www.xxx.com; return 301 https://$server_name$request_uri;} SSL配置(正式环境):
server { listen 443 ssl; server_name xxx.com www.xxx.com; ssl_certificate /usr/local/nginx/ssl/xxx.com_bundle.pem; ssl_certificate_key /usr/local/nginx/ssl/xxx.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /usr/ui/html; index index.html index.htm; } # 其他配置...} 服务器块配置(测试环境):
server { listen 80; server_name test-xxx.com www.test-xxx.com; return 301 https://$server_name$request_uri;} SSL配置(测试环境):
server { listen 443 ssl; server_name test-xxx.com www.test-xxx.com; ssl_certificate /usr/local/nginx/ssl/test-xxx.com_bundle.pem; ssl_certificate_key /usr/local/nginx/ssl/test-xxx.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /usr/test-ui/html; index index.html index.htm; } # 其他配置...} Ⅲ. 创建测试配置文件
在/usr/local/nginx/conf目录下创建nginx.test.conf文件,并添加以下内容:# 测试环境配置server { listen 80; server_name xxx.com www.xxx.com; return 301 https://$server_name$request_uri;}server { listen 443 ssl; server_name test-xxx.com www.test-xxx.com; ssl_certificate /usr/local/nginx/ssl/test-xxx.com_bundle.pem; ssl_certificate_key /usr/local/nginx/ssl/test-xxx.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /usr/test-ui/html; index index.html index.htm; } # 其他配置...} Ⅳ. 启动Nginx
停止当前Nginx服务:nginx -s stop启动Nginx服务:nginx 转载地址:http://xecfk.baihongyu.com/