0
点赞
收藏
分享

微信扫一扫

nginx 路径代理 go服务器 gin 设置代理

nginx 路径代理 go服务器 gin 设置代理

通过 nginx 可以实现代理。

在 ​​http://localhost/qr​​​ 中请求 ​​http://localhost:9999​​ 的数据时,会提示跨域问题,此时可以通过 nginx 代理一下来实现跨域请求。

这里设置 在请求 ​​http://localhost/qr-portal​​​ 时,实际请求的是 ​​http://localhost:9999​​ 这个地址

配置如下:

upstream qr_server {                                                         
server localhost:9999;
keepalive 2000;
}


server {
...
location /qr-portal/ {
proxy_pass http://qr_server/;
proxy_set_header Host $host:$server_port;
}
...
}


举报

相关推荐

0 条评论