nginx http重定向https配置說明
nginx http重定向https配置說明
現在什么蘋果,谷歌瀏覽器請求地扯基本都要求使用https了,如何把原來的http協議重定向到https中呢,這里我們可以使用http反向代理軟件nginx。
使用
安裝
yum install nginx -y
配置
cat /etc/nginx
server {
listen 80;
server_name dounine.com www.dounine.com;
return 301 https://www.dounine.com$request_uri;
}
server {
listen 443;
server_name dounine.com dounine.com;
return 301 https://www.dounine.com$request_uri;
}
server {
listen 443;
server_name www.dounine.com;
ssl on;
ssl_certificate /etc/nginx/dounine.crt;
ssl_certificate_key /etc/nginx/dounine.key;
location / {
client_max_body_size 20m;
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
以上配置可將www.dounine.com、dounine.com與https://dounine.com 重定向至https://www.dounine.com地扯中。
注意
記得將防火墻的80與443端口打開。
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關文章
Nginx隱藏index.php和Pathinfo模式配置例子
這篇文章主要介紹了Nginx隱藏index.php和Pathinfo模式配置例子,需要的朋友可以參考下2014-04-04
nginx將https協議反向代理到http協議請求上的實現
本文主要介紹了nginx將https協議反向代理到http協議請求上的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-10-10
Centos7.3 安裝部署Nginx并配置https的方法步驟
這篇文章主要介紹了Centos7.3 安裝部署Nginx并配置https的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-04-04
Nginx反向代理出現502?Bad?Gateway問題解決
在配置Nginx反向代理時遇到502 Bad Gateway錯誤,經過排查發(fā)現是SSL握手問題,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2024-10-10
PHP(FastCGI)在Nginx的alias下出現404錯誤的解決方法
這篇文章主要介紹了PHP(FastCGI)在Nginx的alias下出現404錯誤的解決方法,涉及nginx平臺的相關配置技巧,需要的朋友可以參考下2016-05-05

