[精讚] [會員登入]
847

如何在docker 的nginx 做另一個container的反向代理

環境 docker 中一container 跑 nginx 對外服務80 port, http://server 另一c

分享此文連結 //n.sfs.tw/15540

分享連結 如何在docker 的nginx 做另一個container的反向代理@igogo
(文章歡迎轉載,務必尊重版權註明連結來源)
2021-12-18 22:06:26 最後編修
2021-12-18 22:02:33 By igogo
 

 

環境

 

docker 中一container 跑 nginx   對外服務80 port, http://server

另一container 名為another_web跑 web服務於19090 port , 需要提供對外服務於http://server/user

 

 

設定於nginx container的nginx.conf中

  http {
      server {
            listen 80;

            location /api {
                proxy_pass http://another_web:19090;
                proxy_redirect     off;
                proxy_set_header   Host $host;
                proxy_set_header   X-Real-IP $remote_addr;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header   X-Forwarded-Host $server_name;
            }
      }
    }

 

 

參考

https://stackoverflow.com/questions/39514293/docker-nginx-proxy-how-to-route-traffic-to-different-container-using-path-and-n

END

你可能感興趣的文章

使用expect 讀取外部資料存成陣列 使用expect 讀取外部資料存成陣列

使用vbs設定windows 10 靜態IP setting static ip Set Adapter = GetObject("winmgmts:Win

centos 7 移机出現 dracut-initqueue timeout centos 7 移机出現 dracut-initqueue timeout 處理

雲端校務系統與OPENLDAP帳號整合(2) openldap,雲端校務

網站無障礙規範 https://accessibility.ncc.gov.tw/News/Detail/3238?Category=4

批次檢查tls憑證是否過期 tls憑證一年一簽, 台中市有三百多所學校, 寫成一檔案 skaps.tc.edu.tw www.skaps.tc.ed

隨機好文

vue.js component 在parent與child 傳值 component 在parent與child 傳值

hoc2018灑水機器人 灑水機器人的工作是替行道樹灑水,機器人的灑水範圍有限(左前方、左方、左後方),請寫程式控制機器 人判斷須灑水的狀況。每顆

ubuntu ufw ufw 簡易筆記 原則禁止,例外開放 ufw default deny 啟動ufw sudo ufw enable 關掉

台中市網路應用競賽試場安排(一) 排試場就跟排班或是排課表一樣, 找不到一個都能讓所有人滿意的結果

Spring Boot Maven wrappers maven, mvnw, build command