美文网首页
Nginx配置不同location

Nginx配置不同location

作者: 轻易不懂 | 来源:发表于2020-05-17 23:36 被阅读0次

两个静态网页配置在不同目录

  • 有一个vue静态网页工程目录放在/home/ubuntu/website/dist,包含index.html和static

  • 另有一个隐私协议静态网页放在/home/ubuntu/website/privacy,包含index.html

配置https://xiangqian.space 指向vue静态网页工程,但是https://xiangqian.space/privacy 指向隐私协议。

nginx.conf里server的location部分配置如下:


location / {

    root /home/ubuntu/website/dist;

    try_files $uri $uri/ /index.html =404;

    index index.html =404;

}

location = /privacy {

    root /home/ubuntu/website/privacy;

    try_files $uri /index.html =404;

    index index.html =404;

}

关键是root写清楚index.html所在的目录,index.html搜索的路径是“{root}+{try_files}”所列举的路径,所以try_files里要写上/index.html

nginx里的其它配置解说可以参考https://blog.csdn.net/qq_33862644/article/details/79337348

相关文章

  • Nginx配置不同location

    两个静态网页配置在不同目录 有一个vue静态网页工程目录放在/home/ubuntu/website/dist,包...

  • Nginx 匹配规则

    Nginx 内核源码解析 nginx location 练习 Nginx location 配置踩坑过程分享ngi...

  • nginx基础知识

    nginx主配置文件 nginx.conf 配置文件结构如下: location匹配规则 语法规则location...

  • Nginx路由详解

    本文总结Nginx的location配置策略。结合案例说明location的用法。 location配置语法:lo...

  • Nginx 负载均衡/反向代理配置

    反向代理: 修改nginx配置nginx.conf文件: 在location /{ #...

  • D-46网站服务配置过程

    一、nginx程序location配置方法 作用: 匹配指定的uri信息,可以根据访问不同的uri信息,做出不同处...

  • Nginx配置文件下载(不预览)

    nginx配置指定目录文件下载 server块中新增 location配置:

  • Nginx 跨域设置

    nginx配置文件中,在需要跨域的location内,增加如下配置,重启nginx即可。

  • nginx获取真实ip

    通过Nginx获取用户真实IP nginx配置 location / { proxy_set_header ...

  • nginx实战笔记

    nginx最佳实践 nginx location详解 server_name参数配置 nginx中root和ali...

网友评论

      本文标题:Nginx配置不同location

      本文链接:https://www.haomeiwen.com/subject/cqxyohtx.html