1
初めてNginxを使用しています。Nginx複数のTomcatインスタンスを使用するリバースプロキシのためのコンフィグレーション
- 私は2台のサーバーを持っています。 SERVER ONE(ip:1.2.3.4)SERVER TWO(ip: 5.6.7.8)
- 私はSERVER ONEにnginxを、SERVER TWOにTomcatをインストールしました。
別のポートで実行するようにTomcatを正常に設定しました。私の tomcatは以下のポートで動作しています。
5.6.7.8:8080
5.6.7.8:8081
5.6.7.8:8082私は、Tomcat上で(インスタンスのそれぞれを)私のwarファイルをも展開しています。
が/etc/nginx/conf.dでは、default.confを作成し、以下のように私は私のnginxを設定している
次のリンク
Nginx Configuration
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# Make site accessible from http://localhost/
server_name 1.2.3.4;
location/{
proxy_pass http://www.example.com;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rule
}
location /user/{
proxy_pass http://5.6.7.8:8080$uri;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rule
}
応じてファイルへ
行われた変更
私がSERVER TWに導入したWarファイルの名前Oは例です。 API私は、IP 1.2.3.4を打つ
/user/login?param1=xyz¶m2=abc¶m3=mno
が含まれていは、それがルート(/)に行きます。私は予期した結果を得ています。私はexample.comのページを取得しています。
をヒットした場合
を取得しています.But 1.2.3.4/userを打ったとき、私は期待しています。この同じ結果どのようなすべてのもの、私は私がヒット結果を得るために変更する必要があります
1.2.3.4/userあなたは