核心配置代碼
找到Nginx的配置文件nginx.conf
,修改配置,主要添加了proxy_pass
參數。
#將請求"http:127.0.0.1:80/helloworld" 轉向服務器 "http://127.0.0.1:8081"
server {
listen 80;
server_name 127.0.0.1;
location /helloworld {
proxy_pass http://127.0.0.1:8081; # 表明了所代理的服務器
}