# 服务层

# https://github.com/farwish/alconservice

# alconservice.conf

server {
listen 8090;
root /home/www/alconService/public; location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} location /favicon.ico {
log_not_found off;
access_log off;
} access_log logs/alconservice.access.log;
}

# 前端应用

# front.yk.conf

server {
listen 80;
server_name front.kkys.com; root /home/www/web; location / {
index index.html index.htm index.php;
} location /api/ {
proxy_pass http://dev.kkys.com/yk/;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; #fastcgi_param PATH_INFO $fastcgi_path_info;
#fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

# 社区接口

# yk.up

server {
listen 81;
root /home/www/Yk/public; location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} location /favicon.ico {
log_not_found off;
access_log off;
} access_log logs/yk.access.log;
}

# 检索接口

https://github.com/farwish/alconseek

# speed.up

server {
listen ;
root /home/www/speed/public; location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} location /favicon.ico {
log_not_found off;
access_log off;
} access_log logs/speed.access.log;
}

# 百科接口

# baike.up

server {
listen ;
root /home/www/baike/public; location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} location /favicon.ico {
log_not_found off;
access_log off;
} access_log logs/baike.access.log;
}

# 后端接口总代理

# proxy-all.conf

# 注意路径: 当前文件由nginx.conf引用
include vhost/*.up; upstream yk-backend {
server 127.0.0.1:81;
}
upstream speed-backend {
server 127.0.0.1:82;
}
upstream baike-backend {
server 127.0.0.1:83;
} server {
listen 80;
server_name dev.kkys.com; location / {
root /home/www;
index index.html index.htm index.php;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # 结尾不加/,访问记录是 //frontend/index/detail/1212
# 加了/,访问记录是 /frontend/index/detail/1212
location /yk/ {
proxy_pass http://yk-backend/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
location /speed/ {
proxy_pass http://speed-backend/;
}
location /baike/ {
proxy_pass http://baike-backend/;
}
}

# 用户中心

# ucenter.conf

server {
listen 8092;
root /home/www/ucenter-front; location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
} server {
listen 8093;
root /home/www/ucenter/public; location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
} upstream ucenter-front {
server 127.0.0.1:8092;
} upstream ucenter {
server 127.0.0.1:8093;
} server {
listen 80;
server_name ucenter.com; location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
} location /favicon.ico {
log_not_found off;
access_log off;
} location /pcenter/ {
proxy_pass http://ucenter-front/;
} location /ucenter/ {
proxy_pass http://ucenter/;
}
}

以上 location 的配置是针对 phalcon 框架而言,下面是针对 symfony 应用的。

symfony.conf

server {
listen 80;
server_name symfony.com;
root /home/www/symfony/web; location / {
index index.html index.htm index.php;
try_files $uri /app.php$is_args$args;
} # DEV
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # symfony.com/app.php/some-path
# Remove the internal directive to allow URIs like this.
#internal;
} access_log logs/symfony.access.log;
}

小结:

多应用基于项目拆分的场景或思想,独立开发、独立部署,可以做到互不影响,如同前后端分离一样。

这里大家会发现,反向代理不仅可以简化多应用的部署,还能做到负载均衡,只需增加 upstream机器 就能横向扩展。

其实也完全可以 以大模块的方式整合成一个强大应用,从易维护上来讲更容易一点。两种方式都各有优势。

Link:http://www.cnblogs.com/farwish/p/6128712.html

[Nginx]单机环境的多应用配置的更多相关文章

  1. Twitter Storm:单机环境的安装与配置

    Twitter Storm:单机环境的安装与配置 好久没写博客了,这一段时间一直被导师push着做毕业设计.由于目前的方向偏向于图像识别检索,毕设打算做一个基于分布式计算平台的图像检索系统,查阅相关资 ...

  2. 转:Nginx+Apache环境的安装与配置

    转:http://www.server110.com/nginx/201404/8817.html 我们依然尽可能采用yum来安装我们需要的软件,由系统官方维护的软件,其安全性和稳定性都值得信赖,并且 ...

  3. Nginx+Apache环境的安装与配置

    我们依然尽可能采用yum来安装我们需要的软件,由系统官方维护的软件,其安全性和稳定性都值得信赖,并且容易管理,升级方便,但是在CentOS和RHEL的官方yum源中暂时没有Nginx等软件包,所以我们 ...

  4. windows下配置nginx+php环境

    刚看到nginx这个词,我很好奇它的读法(engine x),我的直译是"引擎x",一般引"擎代"表了性能,而"x"大多出现是表示" ...

  5. MongoDB3.0.x版本用户授权配置(单机环境)

    MongoDB数据库默认情况下是没有做权限控制的,只要能够连接所开放的端口就能进行访问,而且拥有root级别的权限:对于生产环境而言是极不安全的,所以需要建立用户,进行授权控制. 单机环境下的用户授权 ...

  6. solr单机环境配置并包含外部单机zookeeper

    首先和之前一样下载solr-5.3.1.tgz,然后执行下面命令释放文件并放置在/usr/目录下: $ .tgz $ /usr/ $ cd /usr/solr- 这个时候先不用启动solr,因为单机模 ...

  7. (转)windows下配置nginx+php环境

    原文地址 http://www.cnblogs.com/huayangmeng/archive/2011/06/15/2081337.html 刚看到nginx这个词,我很好奇它的读法(engine ...

  8. hbase单机环境的搭建和完全分布式Hbase集群安装配置

    HBase 是一个开源的非关系(NoSQL)的可伸缩性分布式数据库.它是面向列的,并适合于存储超大型松散数据.HBase适合于实时,随机对Big数据进行读写操作的业务环境. @hbase单机环境的搭建 ...

  9. LNMP环境搭建:Nginx安装、测试与域名配置

    Nginx作为一款优秀的Web Server软件同时也是一款优秀的负载均衡或前端反向代理.缓存服务软件 2.编译安装Nginx (1)安装Nginx依赖函数库pcre pcre为“perl兼容正则表达 ...

随机推荐

  1. git客户端安装后,访问不到gitsever解决办法

    1,运行 git Bash 客户端 $ cd ~/.ssh 如果没有此目录则创建一个 $ mkdir ~/.ssh 2,在.ssh目录下 $ ssh-keygen -t rsa -C "你的 ...

  2. burpsuite截断绕过前端限制上传一句话

    设置代理,这里就不说了 打开上传界面 burpsuite开启拦截,上传lurp.hpg 在burp找到上传文件的格式改回原来一句话的格式 上传= =

  3. cs231n spring 2017 lecture10 Recurrent Neural Networks 听课笔记

    (没太听明白,下次重新听一遍) 1. Recurrent Neural Networks

  4. CSS3使用content属性来插入项目编号

    首先可以使用before选择器与after选择器的content属性在元素的前面或者后面插入文字和图像,这里我记录的是利用这个content属性来在项目前插入项目编号,同时可以利用content属性在 ...

  5. HttpClient(二)HttpClient使用Ip代理与处理连接超时

    前言 其实前面写的那一点点东西都是轻轻点水,其实HttpClient还有很多强大的功能: (1)实现了所有 HTTP 的方法(GET,POST,PUT,HEAD 等) (2)支持自动转向 (3)支持 ...

  6. Free Pascal初次体验(有亮点哦)

    感觉上Pascal语言写的非常有条理,和英语很像,应该是比较容易学,但是写起来真的是麻烦的要死,平时一行代码用C/C++可能就是几秒钟,用Pascal就要几分钟,Free Pascal感觉也不是很好用 ...

  7. bzoj:3398 [Usaco2009 Feb]Bullcow 牡牛和牝牛

    Description     约翰要带N(1≤N≤100000)只牛去参加集会里的展示活动,这些牛可以是牡牛,也可以是牝牛.牛们要站成一排.但是牡牛是好斗的,为了避免牡牛闹出乱子,约翰决定任意两只牡 ...

  8. [51nod1357]密码锁

    有一个密码锁,其有N位,每一位可以是一个0~9的数字,开启密码锁需要将锁上每一位数字转到解锁密码一致.这个类似你旅行用的行李箱上的密码锁,密码锁的每一位其实是一个圆形转盘,上面依次标了0,1,...9 ...

  9. Vijos P1113 不高兴的津津【模拟】

    不高兴的津津 描述 津津上初中了.妈妈认为津津应该更加用功学习,所以津津除了上学之外,还要参加妈妈为她报名的各科复习班.另外每周妈妈还会送她去学习朗诵.舞蹈和钢琴.但是津津如果一天上课超过八个小时就会 ...

  10. Codeforces Round #416(Div. 2)-811A.。。。 811B.。。。 811C.dp。。。不会

    CodeForces - 811A A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 meg ...