A single server that handles both HTTP and HTTPS requests
跳转到导航
跳转到搜索
a single server that handles both HTTP and HTTPS requests
A single HTTP/HTTPS server
It is possible to configure a single server that handles both HTTP and HTTPS requests:
server {
listen 80;
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
...
}
强制跳转443
upstream proxy_node_nuxt_mobile {
ip_hash;
server 172.116.0.8:3334 weight=1 max_fails=2 fail_timeout=10s;
server 172.116.0.14:3334 weight=1 max_fails=2 fail_timeout=10s ;
}
server {
listen 80;
server_name m..com;
rewrite ^/(.*)$ https://m..com/$1 permanent;
}
server {
listen 443 ssl;
server_name m..com;
#root /var/www/m..com;
index index.html index.htm;
#ssl on; ng 新的版本不能这样用了
ssl_certificate /var/package/ssl/om.crt;
ssl_certificate_key /var/package/ssl/Skey;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
# proxy_pass http://172.16.00.8:334;
add_header X-Frame-Options SAMEORIGIN;
proxy_pass http://proxy_node_nuxt_mobile;
}
error_log /var/log/nginx/m..error.log;
access_log /var/log/nginx/m.caccess.log;
# include /etc/nginx/sites-available/blockips.conf;
}
参考
http://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server