nginx配置代理端口


1、server為我們當前要配配置的ip以及代理端口號
  ` server{
         listen       80;
         server_name  localhost;
    }`
2、location為我們需要代理的ip設置,包括重寫,設置超時等等。
  `
   localtion /api {
        rewrite '^/xxl-job-admin/(.*)' /api/$1;
        proxy_pass http://172.31.14.168:8080/xxl-job-admin
   }
  `
  (.*)'.表示任意除n\字符之外的任意字符 *表示可0次或者多次出現匹配'
  rewrite為重寫url設置,表示我們訪問/xxl-job-admin時,重寫前綴為/api
  這樣就可以訪問localhost來訪問172.31.14.168:8080了
3、root指向根路徑下的static文件夾 默認渲染index.html頁面
  、
    location / {
        root   static;
        index  index.html;
    }`
4、nexin -T 打印當前的輸入配置,用來檢配置是否有誤,以及亂碼報錯


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM