nginx 配置访问路径

下面两个 location ,

(1)后面如果是 / ,访问的路径 :

ip:端口/index.html  即可访问到 /usr/share/nginx/html/vue 下面的网页
(2)如果后面有东西,访问的路径:

ip:端口/app/dist/index.html  但是 nginx 找的路径,是:/usr/share/nginx/html/vue/app/dist  

是把  app/dist 拼接在 root 下的目录最后面的,而不是前面的

复制代码
server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html/vue;
        index  index.html index.htm;
    }
    
    location /app/dist/ {
        root   /usr/share/nginx/html/vue;
        index  index.html index.htm;
    }
    ……
}
复制代码

 

posted @   雪化山河  阅读(5624)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示