所以我有一个应用程序可以在http://localhost:4206传播一个Web服务。
我已将应用程序复制到EC2实例,现在想要启动该服务,但允许所有人(外部消费者)点击该服务。我知道我可以配置nginx将端口8080(外部)的转发代理添加到我的服务器端口(4206)。
我找到了以下指南:https://ef.gy/using-nginx-as-a-proxy-server
但是,我不确定本指南到底应该做些什么......
这段代码对我来说应该是什么样的?
server {
listen 8080;
location / {
resolver 8.8.8.8;
proxy_pass http://$http_host$uri$is_args$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
有些方向值得赞赏。谢谢!
答案 0 :(得分:1)
server {
# Port
listen 8080;
# Set the name of the virtual server
server_name _;
# Proxy pass everything to http://localhost:4206/
location / {
proxy_pass http://localhost:4206;
# Set the proxied host
proxy_set_header Host localhost;
}
}
在此处阅读有关proxy_pass和其他指令的更多信息:http://nginx.org/en/docs/http/ngx_http_proxy_module.html