[英]Nginx reverse proxy for domain.com:port
I have a web application running and publicly available on http://example.com:8099
我有一个 web 应用程序正在运行并在
http://example.com:8099
上公开可用
To run the application over HTTPS, the app documentation suggests that we use a standard reverse proxy because it does not natively support HTTPS.要在 HTTPS 上运行应用程序,应用程序文档建议我们使用标准反向代理,因为它本身不支持 HTTPS。 All the guides I found is about proxying with just a domain root and does not take the port into consideration.
我发现的所有指南都是关于仅使用域根代理的,并且没有考虑端口。
To begin with, I'm not sure which port should I even listen to in the first place.首先,我不确定首先应该听哪个端口。 Is it 443 , or 8099 ?
是443还是8099 ?
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com;
error_log /var/log/nginx/sonar-error.log;
access_log /var/log/nginx/sonar-access.log;
location / {
proxy_pass http://localhost:8099;
}
}
In my server (AWS EC2 instance), the application is also running at the same port http://localhost:8099
as in the domain.在我的服务器(AWS EC2 实例)中,应用程序也在与域中相同的端口
http://localhost:8099
上运行。
I've tried different configurations and checked whether anything is logged in to these log files.我尝试了不同的配置并检查是否有任何内容登录到这些日志文件中。 But these were empty.
但这些都是空的。 So I don't think I'm doing it right.
所以我不认为我做得对。
You need to listen on port 443 (the port Nginx is allowing connections on), and proxy_pass
to 8099 (the port application traffic is being passed to).您需要监听端口 443(端口 Nginx 允许连接),并且
proxy_pass
到 8099(端口应用程序流量被传递到)。
Your also need to ensure the server_name
line contains the DNS name that traffic is being requested to, or is an an underscore inside speech marks ( "_"
) to ensure allrequests are matched to that server entry.您还需要确保
server_name
行包含请求流量的 DNS 名称,或者是语音标记( "_"
)内的下划线,以确保所有请求与该服务器条目匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.