我一直在試圖設置nginx作爲碼頭的代理。我想按照this answer中的解釋做一些事情,但Jetty不響。如何將nginx配置爲代理到碼頭?
我創建了一個.war
,我把它放在~/jetty/jetty-dist/webapps/web_test-0.1.0-SNAPSHOT-standalone.war
說,我要使用的域example.com IP地址爲198.51.100.0。
我也複製/etc/nginx/sites-available/default
到文件example.com
,我把它放在同一個目錄下。
你能幫我配置nginx作爲代理到碼頭嗎?我知道網上有很多關於如何做到這一點的參考文獻,但他們都不一樣,我感到困惑。
我需要在nginx中做什麼特定的更改?我需要在jetty.xml中做什麼更改?我是否需要進行其他更改?我的應用程序將在example.com/index.html提供嗎?
目前Nginx的狀態如下複製:
upstream jetty {
server 127.0.0.1:8080 fail_timeout=0
}
server {
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;
location/{
proxy_pass http://jetty
try_files $uri $uri/ =404;
}
編輯
我在想,如果我需要在所有使用碼頭。在this setup他只是使用戒指,這似乎超級簡單?我通過使用jetty獲得什麼?
在碼頭6,如果你有 $ {} jetty.home /contexts/myapp.xml 隨着碼頭9.0,將其移動到 $ {} jetty.home /webapps/myapp.xml 隨着碼頭9.1 +,將其移動到 $ {jetty.base} /webapps/myapp.xml –