我在網路上找解法,試完後不是沒效果就是跟我問題沒直接的關係(很多都是說 php 的)
這是我的配置(以訪問 tomcat 練習)
最一開始的默認配置長這樣
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
               #  這行我自己加的 #
                proxy_pass http://127.0.0.1:8080;
                try_files $uri $uri/ =404;
        }
}
我另外在下面寫一個
server {
       listen 9001;
       listen [::]:9001;
       server_name 192.168.0.102;
       location ~ /edu/ {
               proxy_pass http://127.0.0.1:8000;
       }
}
然後如果直接從 8080 去訪問可以正常顯示,換做以從 9001 就不行了
請問這樣子該怎麼解決? 找不到為什麼
防火牆目前是關閉的狀態
error message
connect() failed (111: Connection refused) while co    nnecting to upstream, client: 192.168.0.101, server: 192.168.0.102, request: "GET /edu/b.html     HTTP/1.1", upstream: "http://127.0.0.1:8000/edu/b.html", host: "www.123.com:9001" 

你先 ssh 進去 Ubuntu 終端機裡面, 再輸入:
curl http://127.0.0.1:8080
會有資料出來嗎?
server {
       listen 9001;
       listen [::]:9001;
       server_name 192.168.0.102;
       location ~ /edu/ {
               proxy_pass http://127.0.0.1:8000;
       }
}
看不懂為甚麼這裡是 proxy_pass http://127.0.0.1:8000;,你明明說要導到8080?