Resin多端口设置以及Nginx反向代理设置(转)

 
 
在resin中跑两个应用,分别是gd和qd,这两个应用使用的端口分别为:


gd:监视:6800 应用:8080
qd:监视:6801 应用:8081

则resin.xml主要配置如下:


<cluster id="gd">
    <server-default>
      <jvm-arg>-Xmx512m</jvm-arg>
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-server</jvm-arg>
    </server-default>
        <resin:import path="${resin.home}/conf/app-default.xml"/>
    <server id="gd" address="127.0.0.1" port="6800">
        <http id="" port="8080"/>
    </server>
    <host id="" root-directory=".">
           <web-app id="/" root-directory="/data0/htdocs/gd/" />
    </host>
  </cluster>
 
  <cluster id="qd">
    <server-default>
      <jvm-arg>-Xmx512m</jvm-arg>
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-server</jvm-arg>
    </server-default>
        <resin:import path="${resin.home}/conf/app-default.xml"/>
    <server id="qd" address="127.0.0.1" port="6801">
        <http id="" port="8081"/>
    </server>
    <host id="" root-directory=".">
           <web-app id="/" root-directory="/data0/htdocs/qd/"/>
    </host>
  </cluster>

则操作命令为:


./resin.sh restart|stop|start -server gd
./resin.sh restart|stop|start -server qd

另外gd和qd应用需要部署转发到80端口,各使用相应域名:
gd: gd.forzw.com
qd: qd.forzw.com

则在nginx中的配置为:


server
  {
  listen 80;
  server_name gd.forzw.com;
  index index.jsp index.html index.htm ;
  root /data0/htdocs/gd;
 
  if (-d $request_filename)
  {
  rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
  }
 
  location / {
  include /usr/local/webserver/nginx/conf/proxy_resin.conf;
  proxy_pass http://localhost:8080;
  proxy_set_header X-Real-IP $remote_addr;
  }
  }
 
  server
  {
  listen 80;
  server_name qd.forzw.com;
  index index.jsp index.html index.htm ;
  root /data0/htdocs/qd;
 
  if (-d $request_filename)
  {
  rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
  }
 
  location / {
  include /usr/local/webserver/nginx/conf/proxy_resin.conf;
  proxy_pass http://localhost:8081;
  proxy_set_header X-Real-IP $remote_addr;
 
  }
  }