Nginx请求转发

Nginx请求转发

  • 下载安装nginx

  • 只需配置nginx.conf

server {
    client_max_body_size   100M;
    listen       9001;                    //对外暴露端口
    server_name  localhost;

location ~ /service_edu/ {				  //如果路径中有service_edu,则转发到本地8001端口			
    proxy_pass http://localhost:8001;  
}

location ~ /service_oss/ {				  //如果路径中有service_oss,则转发到本地8002端口
    proxy_pass http://localhost:8002;
}

location ~ /service_vod/ {				  //如果路径中有service_vod,则转发到本地8003端口
    proxy_pass http://localhost:8003;
}
}

Linux相关命令

去到nginx目录下

./nginx                     //启动nginx
./nginx -s reload           //重启
posted @ 2020-09-12 21:23  天气晴21℃  阅读(247)  评论(0编辑  收藏  举报