nginx配置反向代理路徑問題

用nginx上了個前端項目,踩了路徑的坑,記錄一下:

server {
        listen       2077;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        # 例如:你前端的請求路徑是這樣的 /api/v1/getData
        # ^~ /api/ 匹配以‘/api/’開頭的請求,請求會被拼接成:http://10.10.10.10:8080/v1/getData
		location ^~ /api/ {
			proxy_pass http://10.10.10.10:8080/;
		}
	    error_page   500 502 503 504  /50x.html;
	     location = /50x.html {
	         root   html;
	     }
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章