Nignx同时支持http和https

upstream z1 {
        server 172.111.111.111:80 max_fails=1 fail_timeout=10s;
}
# server {
#    listen 80;
#    server_name www.abc.cn;
#    rewrite ^(.*)$ https://${server_name}$1 permanent;
# }
server {
        listen  80; # 加上80
        listen  443 ssl;
        server_name  www.abc.cn;
        client_max_body_size 100M;
#       ssl on;   #主要这个要注释掉
        ssl_certificate cert/8684361_www.59177.cn.pem;
        ssl_certificate_key cert/8684361_www.59177.cn.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
#       charset koi8-r;
        access_log  /var/log/nginx/host.access.log  main;

         location / {
                #root /opt/app/ROOT;
                root /opt/app/newMainView;
                index index.html index.htm;
        }       

        location /ROOT {
                root /opt/app;
                index index.html index.htm;
        }

        location ^~ /mailbox/ {
                proxy_pass http://z1;
                include proxy_params;
        }

        location ^~ /medical/ {
                proxy_pass http://120.77.245.145/medical/;
                include proxy_params;
        }

        location ^~ /upload/ {
                proxy_pass http://120.77.245.145/upload/;
                include proxy_params;
        }

        location /ubox {
                root /opt/app/;
                index index.html index.htm;
        }
    
        location /appDownload {
                root /opt/app/;
                index index.html index.htm;
        }

        location /weixin {
                root /opt/app/;
                index index.html index.htm;
         }

        location /wxhelp {
                root /opt/app/;
                index index.html index.htm;
        }

        error_page  404              /404.html;
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
                root   /usr/share/nginx/html;
        }

}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容