Nginx: 解决 `Vue history` 模式刷新地址栏出现 500 和 https 配置

581 阅读1分钟

Nginx 二级代理配置 和 解决 Vue history 模式刷新地址栏 500

http {
....
    server {
            # 对外端口
            listen       80;
            server_name  localhost;

            #charset koi8-r;
            #access_log  logs/host.access.log  main;

            # vue3demo 为二级代理路由 适配 `history` 模式
            location /vue3demo {
               alias C:\\myproject\\vue3-ts-cms;
               index index.html index.htm;
               try_files $uri $uri/ /vue3demo/index.html;  
            }
             # blog 为二级代理路由
            location /blog/ {
                proxy_pass http://localhost:8088/;
                proxy_pass_header Server;
            }

            location / {
                root   html;
                index  index.html index.htm;
            }
    }
....
}

Https 证书配置

worker_processes  1;
....
events {
    worker_connections  1024;
}
....
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    
    server {
       # 对外端口
       listen   3000 ssl;
       
       # 域名设置
       server_name  XX.XXX.com;
       ssl_certificate      ../cert/6523688.com.pem;
       ssl_certificate_key  ../cert/6523688.com.key;
       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;
       ssl_ciphers  HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers  on;

       location / {
            # 代理到本地服务
            proxy_pass   http://127.0.0.1:3333;
        }
    }
}
....