nginx http重定向https配置說明
更新時間:2017年04月14日 08:49:23 投稿:lqh
這篇文章主要介紹了nginx http重定向https配置說明的相關(guān)資料,需要的朋友可以參考下
nginx http重定向https配置說明
現(xiàn)在什么蘋果,谷歌瀏覽器請求地扯基本都要求使用https了,如何把原來的http協(xié)議重定向到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端口打開。
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
您可能感興趣的文章:
相關(guān)文章
分布式架構(gòu)中關(guān)于正向代理反向代理面試提問
這篇文章主要為大家介紹了分布式架構(gòu)中關(guān)于正向代理反向代理的面試提問,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步2022-03-03
nginx用正則表達式實現(xiàn)泛域名自動匹配目錄的方法
這篇文章主要介紹了nginx用正則表達式實現(xiàn)泛域名自動匹配目錄的相關(guān)知識,本文給大家介紹的非常詳細,對大家的學(xué)習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-05-05

