修改nginx.conf

前提:
前端项目打包时,修改vue.config.js配置

module.exports = defineConfig({
  publicPath: './',
  ......
)}

举例

  1. 通过前缀区分多个前端项目
        server {
                listen 443 ssl;
                server_name localhost;
                ssl_certificate         /var/lib/thci/pki/app.pem;
                ssl_certificate_key     /var/lib/thci/pki/app-key.pem;
                proxy_set_header Remote_addr $remote_addr;
                 // 原本的
                location / {
                        root /etc/nginx/dist;
                        index index.html index.htm;
                        try_files $uri $uri/ /index.html;
                }
                 // 新加的
                 // 注意得用 alias 
                location /访问前缀名 {
                        alias /etc/nginx/包名;
                        index index.html index.htm;
                        try_files $uri $uri/ /cloudspace/index.html;
                        autoindex off;
                }
  1. 通过端口号区分不同项目
		server {
                listen 998 ssl; //访问端口号
                server_name localhost;
                ssl_certificate         /var/lib/thci/pki/app.pem;
                ssl_certificate_key     /var/lib/thci/pki/app-key.pem;
                proxy_set_header Remote_addr $remote_addr;
                location / {
                        root /etc/nginx/报名;
                        index index.html index.htm;
                   ...............

————————————————
实际使用中发现,在75.x老版本谷歌浏览器上,使用这个形式访问页面,空白一片
报错:
在这里插入图片描述

未解决。。。。

更多推荐