nginx http重定向https配置說明
現在什么蘋果,谷歌瀏覽器請求地扯基本都要求使用https了,如何把原來的http協議重定向到https中呢,這里我們可以使用http反向代理軟件nginx。
使用
安裝
1
|
yum install nginx -y |
配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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端口打開。
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
原文鏈接:http://blog.csdn.net/dounine/article/details/53734631