NginxでJetty動かしたくなった



Nginx自体の設定はこのあたりを

まず、JDKの比較的新しいのを入れたいので、

yum search jdk
〜略〜
=============================== N/S Matched: jdk ===============================
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser
                   : plug-in and Web Start implementation
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
ldapjdk.x86_64 : The Mozilla LDAP Java SDK

JDK1.7あたりを入れます。

yum install java-1.7.0-openjdk.x86_64

http://download.eclipse.org/jetty/からJettyをダウンロードして解凍

wget http://download.eclipse.org/jetty/stable-9/dist/jetty-distribution-9.2.6.v20141205.tar.gz
tar xvfz jetty-distribution-9.2.6.v20141205
cd jetty-distribution-9.2.6.v20141205
java -jar start.jar

nginxの設定はこんな感じです。

upstream java {
  server 127.0.0.1:8080;
}

server {
    listen       80;
    server_name java.axtstar.com;
    location ^~ / {
            proxy_pass http://java;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    }
}

これでjava.axtstar.comでjettyにアクセスできます…がdeamon化しないと…
ここを参考にデーモン化スクリプトを作成しました。