linux 下配置 resin+nginx

找到resin.xml配置文件 增加cluster节点

<!-- test start -->
    <cluster id="test">  这里的test 是你的项目名称
     <root-directory>.</root-directory>
     <server-default>
        <jvm-arg>-Xmx512m</jvm-arg>
        <jvm-arg>-Xms512m</jvm-arg>
        <jvm-arg>-Xmn128M</jvm-arg>
     <jvm-arg>-XX:-UseGCOverheadLimit</jvm-arg>
        <jvm-arg>-Xss50M</jvm-arg>
        <jvm-arg>-XX:PermSize=128M</jvm-arg>
        <jvm-arg>-XX:MaxPermSize=512M</jvm-arg>
        <jvm-arg>-XX:SurvivorRatio=8</jvm-arg>
        <jvm-arg>-XX:MaxTenuringThreshold=7</jvm-arg>
        <jvm-arg>-XX:GCTimeRatio=19</jvm-arg>
        <jvm-arg>-XX:+UseParNewGC</jvm-arg>
        <jvm-arg>-XX:+UseConcMarkSweepGC</jvm-arg>
        <jvm-arg>-XX:+CMSPermGenSweepingEnabled</jvm-arg>
        <jvm-arg>-XX:+CMSClassUnloadingEnabled</jvm-arg>
        <jvm-arg>-XX:+UseCMSCompactAtFullCollection</jvm-arg>
        <jvm-arg>-XX:CMSFullGCsBeforeCompaction=2</jvm-arg>
        <jvm-arg>-XX:-CMSParallelRemarkEnabled</jvm-arg>
        <jvm-arg>-XX:+DisableExplicitGC</jvm-arg>
        <jvm-arg>-XX:CMSInitiatingOccupancyFraction=70</jvm-arg>
        <jvm-arg>-XX:SoftRefLRUPolicyMSPerMB=0</jvm-arg>
        <jvm-arg>-XX:+PrintClassHistogram</jvm-arg>
        <jvm-arg>-XX:+PrintGCDetails</jvm-arg>
        <jvm-arg>-XX:+PrintGCTimeStamps</jvm-arg>
        <jvm-arg>-XX:+PrintGCApplicationConcurrentTime</jvm-arg>
        <jvm-arg>-XX:+PrintGCApplicationStoppedTime</jvm-arg>
        <jvm-arg>-Xloggc:log/gc.log</jvm-arg>
        <jvm-arg>-XX:+HeapDumpOnOutOfMemoryError</jvm-arg>
        <jvm-arg>-XX:HeapDumpPath=/data/logs/heap/test/dump</jvm-arg>
     <jvm-arg>-Xdebug</jvm-arg>
        <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
 <jvm-arg>-Dcom.sun.management.jmxremote.ssl=false</jvm-arg>
 <jvm-arg>-Dcom.sun.management.jmxremote.password=false</jvm-arg>
 <jvm-arg>-Dcom.sun.management.jmxremote.authenticate=false</jvm-arg>
 <memory-free-min>5M</memory-free-min>
        <thread-max>1024</thread-max>
        <socket-timeout>65s</socket-timeout>
        <keepalive-max>2048</keepalive-max>
        <keepalive-timeout>15s</keepalive-timeout>
        <http address="*" port="8095"/>这里的端口号必须唯一 是你访问项目的端口号,也是要和nginx配置的端口号一致
     </server-default>
     <server id="test" address="127.0.0.1" port="9124">这个端口可以随意      </server>
     <host id="" root-directory=".">
        <web-app id="/test"  document-directory="/data/service/test" archive-path="/data/jenkins/Test.war" redeploy-mode="automatic"/>
        <stdout-log path="/data/logs/test/access.log" timestamp="" rollover-period="1D"/>
        <stderr-log path='/data/logs/test/error.log' timestamp="" rollover-period='1D'/>
     </host>
   </cluster>
id  项目访问路径

document-directory 项目包war解压路径

archive-path项目war包路径

stdout-log path 日志路径


<!--test  end -->

这样配置好 启动resin  就可以访问test项目  http://(linuxIP地址):8095(上面设置的端口号)/test项目名 http://localhost:8095/test

 

我们想不输入端口号就可以访问这个项目,那么可以使用nginx反向代理来实现。

下面配置nginx来反向代理

找到nginx.conf配置文件 修改该配置文件

增加 upstream  test{
        server  127.0.0.1:8095; 这里的端口号要与resin中配置test的端口号一致
    }

 

定义location

 

location ^~/test/{
            proxy_pass http://test;  页面访问路径
            proxy_redirect  default;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header Cookie     $http_cookie;
            proxy_next_upstream  http_502  http_504 error timeout invalid_header;
            client_max_body_size 80m;
        }

还有一些属性配置 这里就不说了 主要配置就是这两个地方

启动nginx 在浏览器中输入 http://localhost/test

如果能正常访问 那说明配置nginx代理成功了。

你可能感兴趣的:(nginx,linux,resin)