nginx 配置多个主机

时间:2023-01-01 08:41:42
<pre name="code" class="html">    server {
listen 8001;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root /var/www/zjzc-web-frontEnd;
index index.html;
}
location /backoffice {
root /var/www/;
index index.html index.htm;
} location /zjzc-hy-front {
root /var/www/;
index index.html index.htm;
} location /zjzc-hy-web-admin {
root /var/www/;
index index.html index.htm;
} zjtest7-frontend:/var/www/zjzc-web-frontEnd# curl http://192.168.32.76:8001/backoffice/
hello backoffce
zjtest7-frontend:/var/www/zjzc-web-frontEnd# curl http://192.168.32.76:8001/zjzc-hy-front/
hello zjzc-hy-front
zjtest7-frontend:/var/www/zjzc-web-frontEnd# curl http://192.168.32.76:8001/zjzc-hy-web-admin/
hello zjzc-hy-web-admin
zjtest7-frontend:/var/www/zjzc-web-frontEnd# curl http://192.168.32.76:8001/
test jj 20160823 结合haproxy 跳转:
acl mgr_req path_beg -i /backoffice
use_backend mgrserver_8001 if mgr_req acl mgr_req path_beg -i /zjzc-hy-front
use_backend mgrserver_8001 if mgr_req acl mgr_req path_beg -i /zjzc-hy-web-admin
use_backend mgrserver_8001 if mgr_req acl url_static path_end .html .gif .png .jpg .css .js
use_backend mgrserver_8001 if url_static default_backend mgrserver_8001 zjtest7-haproxy:/root# curl http://www.zjtest7.com/backoffice/
hello backoffce
zjtest7-haproxy:/root# curl http://www.zjtest7.com/backoffice/
hello backoffce
zjtest7-haproxy:/root# curl http://www.zjtest7.com/zjzc-hy-front/
hello zjzc-hy-front
zjtest7-haproxy:/root# curl http://www.zjtest7.com/zjzc-hy-web-admin/
hello zjzc-hy-web-admin
zjtest7-haproxy:/root# curl http://www.zjtest7.com/
test jj 20160823 location ^~ /t/ {
root /www/root/html/;
}
如果一个请求的URI是/t/a.html时,web服务器将会返回服务器上的/www/root/html/t/a.html的文件。
														
		

nginx 配置多个主机的更多相关文章

  1. Centos7 nginx配置多虚拟主机过程

    一.前提准备 1.已经安装好了的Centos7服务器 2.ip 为192.168.1.209   [本次的配置ip] 3.确定防火墙等已经关闭 二.nignx配置文件参数详解 要配置多台虚拟主机,就需 ...

  2. nginx配置之虚拟主机功能

    虚拟主机功能: 一个nginx下运行多个网址(站点域名) 方式一:nginx.conf中的http{}中的每一个server{}就是一个站点(相同端口): #虚拟主机1 server { listen ...

  3. LNMP配置——Nginx配置 —— 默认虚拟主机

    一.配置 首先修改配置文件 #vi /usr/local/nginx/conf/nginx.conf 在最后一个结束符号}前加一行配置: include vhost/*.conf; 意思就是/usr/ ...

  4. nginx 配置虚拟主机

    文章转载自:http://www.ttlsa.com/html/1571.html 上篇说道我们的nginx是安装在/usr/local/nginx/ cd conf 我们现在把所有的虚拟主机放在一个 ...

  5. nginx常用配置系列-虚拟主机

    本来准备详尽的出一份nginx配置讲解,但nginx功能配置繁多,平常使用中使用最多的一般有: 1. 虚拟主机配置 2. HTTPS配置 3. 静态资源处理 4. 反向代理 ============= ...

  6. Nginx配置多个基于域名的虚拟主机&plus;实验环境搭建&plus;测试

    标签:Linux 域名 Nginx 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://xpleaf.blog.51cto.com/9 ...

  7. 第四百零二节,Django&plus;Xadmin打造上线标准的在线教育平台—生产环境部署,uwsgi安装和启动,nginx的安装与启动,uwsgi与nginx的配置文件&plus;虚拟主机配置

    第四百零二节,Django+Xadmin打造上线标准的在线教育平台—生产环境部署,uwsgi安装和启动,nginx的安装与启动,uwsgi与nginx的配置文件+虚拟主机配置 软件版本  uwsgi- ...

  8. nginx笔记 安装nginx 配置 反向代理 多虚拟主机

    1,检测linux上是否 通过yum安装了nginxrpm   -qi  nginx 2.安装nginx之前的依赖包yum install gcc patch libffi-devel python- ...

  9. nginx配置虚拟主机vhost的方法详解

    Nginx vhost配置,可实现基于ip.端口号.servername的虚拟主机,同时可避免直接修改主配置文件.在nginx下配置虚拟主机vhost非常方便.这篇文章主要介绍了nginx配置虚拟主机 ...

随机推荐

  1. MySQL查询测试经验

    测试表geoinfo,整个表超过1100万行,表结构: CREATE TABLE `geoinfo` ( `objectid` ) NOT NULL AUTO_INCREMENT , `latitud ...

  2. ArrayList与List对象用法与区别

    比如: 代码如下 复制代码 string[] s=new string[3];//赋值s[0]="a";s[1]="b";s[2]="c"; ...

  3. jCallout 实现气泡提示

    在提交表单前.焦点转移后或者 keyup 时往往需要对输入的文本就行检验,如果输入内容不符合相关约定则要进行提示或警告,有一个叫 jCallout 的插件可以轻松实现该功能,该插件基于  jQuery ...

  4. HUB主要芯片方案

    HUB主要品牌:慧荣.擎泰.联盛  安国.创惟 创惟GL850G简介:拥有低耗电.温度低及接脚数减少等产品特性.它支援4个下游连接埠,采用48 pin LQFP封装,可完全支援USB 2.0/1.1规 ...

  5. ubuntu 安装LNMP

    How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 12.04 PostedJune 13, 2012 802.8kviews ...

  6. make的参数

    转载自 陈皓<跟我一起写 Makefile> 下面列举了所有GNU make 3.80版的参数定义.其它版本和产商的make大同小异,不过其它产商的make的具体参数还是请参考各自的产品文 ...

  7. C&num; 字符串的连接

    1.利用 "+"(加号)运算符: string str = "Hello"+ "World": console.WriteLine(str) ...

  8. php封装curl&comma;模拟POST和GET请求HTTPS请求

    <?php /** * @title 封装代理请求 * @author victor **/ class ApiRequest { /** * curl提交数据 * @param String ...

  9. 浅谈HIbernate

    Hiberbate是面向对象,需要把对象和数据库进行映射.与数据库无关,操作的是对象,会根据数据源和数据库的方言生成对应的sql语句进行查询,是一个优秀的java持久层解决方案,是当今主流的对象-关系 ...

  10. Win32 API编程:使用CreateProcess创建新进程

    #include <windows.h> #include <tchar.h> #include <stdio.h> int main(int argc, char ...