在配置文件中增加多个location,每个location对应一个项目

比如使用8066端口,location / 访问官网; location /demo访问培训管理系统
配置多个站点
我选择了配置多个location。

   location / {
root /data/html/;
index index.html index.html;
}
location /demo{
root /data/trainning/;
index index.html index.html;
}

配置完以后访问。http://xxxx/train 提示404
找了好久才搞明白, location如果一个特定的url 要使用别名,不能用root,alias指定的目录是准确的,root是指定目录的上级目录,改动后即可以使用了

location /train {
alias /data/trainning/;
index index.html index.html;
}

Nginx一个server配置多个location的更多相关文章

  1. Nginx一个server配置多个location(使用alias)

    公司测试环境使用nginx部署多个前端项目.网上查到了两个办法: 在配置文件中增加多个location,每个location对应一个项目比如使用80端口,location / 访问官网: locati ...

  2. Nginx httpS server配置

    Nginx httpS 配置 配置同时支持http和httpS协议: server { listen ; #backlog:每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包 ...

  3. Nginx(六):配置解析之location解析

    nginx成为非常流行的代理服务软件,最根本的原因也许是在于其强悍性能.但还有一些必要的条件,比如功能的完整,配置的易用,能够解决各种各样的实际需求问题,这些是一个好的软件的必备特性. 那么,今天我们 ...

  4. Nginx同server配置下配置多个localhost路由地址

    nginx多页面路由配置,进入 nginx/conf/nginx.conf: http { ...... server { listen 80; server_name localhost; loca ...

  5. nginx多server配置记录

    直接在配置文件(/etc/nginx/nginx.conf)中添加如下代码: server { listen 8080; server_name 192.168.100.174:8080; root ...

  6. nginx下面server配置

    haomeiv配置 log_format www.haomeiv.com '$remote_addr - $remote_user [$time_local] "$request" ...

  7. nginx一个端口配置多个不同服务映射

    upstream tomcat_server{ server 127.0.0.1:8087; server 192.168.149.117:8088; } server { listen 8088; ...

  8. Nginx一个server主机上80、433,http、https共存

    如果一站点既要80 http访问,又要443https访问. 要让https和http并存,不能在配置文件中使用ssl on,配置listen 443 ssl; 实例 server { listen ...

  9. nginx.conf及server配置

    #服务运行用户 user sysadmin www; #工作进程数 worker_processes 4; #错误日志位置 error_log /data/sysadmin/service_logs/ ...

随机推荐

  1. pycharm问题

    Pycharm 出现Unresolved reference '' 错误的解决方法:http://www.mamicode.com/info-detail-2190842.html

  2. Linux 永久挂载镜像文件和制作yum源

    Linux mount命令是经常会使用到的命令,它用于挂载Linux系统外的文件. 1.镜像挂载到系统指定目录下:[root@master cdrom]#  mount -t auto  /mnt/c ...

  3. JAVA语言程序设计课后习题----第一单元解析(仅供参考)

    1 本题是水题,基本的输出语句 public class test { public static void main(String[] args) { // 相邻的两个 "" 要 ...

  4. Windows下Mysql 用户忘记密码时修改密码

    一般这种情况都可以用安全模式下修改来解决.安全模式下即跳过权限检查,输入账号后直接登录进mysql 1.使用管理员权限打开dos窗口,进入mysql安装目录的bin文件夹下,将Mysql服务关闭 sc ...

  5. python 获取安装包apk, ipa 信息

    # -*- coding:utf-8 -*- import re import os import zipfile from biplist import * from androguard.core ...

  6. Vue错误集

    1.Component template should contain exactly one root element. If you are using v-if on multiple elem ...

  7. 第二章 Vue快速入门--12 事件修饰符的介绍

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  8. SOA架构分析

    SOA架构的定义: 面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)进行拆分,并通过这些服务之间定义良好的接口和契约联系起来.接口是采用中立的方式进行定义的,它应该独立于 ...

  9. 在MariaDB导入sql文件出现乱码解决方案

    第一方式: 命令: mysql -u(用户名) -p --default-character-set=utf8(设置编码) data_name(数据库名)<文件路径 示例: 这时,会有一个假死的 ...

  10. BZOJ 2219 数论之神 (CRT推论+BSGS+原根指标)

    看了Po神的题解一下子就懂了A了! 不过Po神的代码出锅了-solve中"d-temp"并没有什么用QwQQwQQwQ-应该把模数除以p^temp次方才行. 来自BZOJ讨论板的h ...