大佬教程收集整理的这篇文章主要介绍了centos nginx https 配置,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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:1R_80_11845@; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!@H_306_22@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:1R_80_11845@; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!@H_306_22@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 { } }
以上是大佬教程为你收集整理的centos nginx https 配置全部内容,希望文章能够帮你解决centos nginx https 配置所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。