简体   繁体   English

Nginx 反向代理域。com:端口

[英]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.

相关问题 nginx反向代理到本地主机 - nginx reverse proxy to localhost Rails 设计 Omiauth 回调返回 domain.com:443 而不是 https://domain.com - Rails Devise Omiauth callback return domain.com:443 instead of https://domain.com 从domain.org到domain.com的直接流量 - Direct traffic from domain.org to domain.com 如何在AWS Route 53中将非www domain.com重定向到www domain.com(WordPress博客)? - How to redirect non-www domain.com to www domain.com(WordPress blog) in AWS Route 53? Route 53 aws www.domain.com 有效,但 domain.com 无效 - Route 53 aws www.domain.com works but domain.com not AWS S3 CloudFront - 从https://www.domain.com重定向到https://domain.com - AWS S3 CloudFront - redirect from https://www.domain.com to https://domain.com 将www.domain.com和domain.com与EC2和Route53一起使用 - Use www.domain.com and domain.com with EC2 and Route53 如何将 www.domain.com 指向 aws 而 domain.com 指向其他地方 - How to point www.domain.com to aws while domain.com point to somewhere else HTTPS并在AWS Elastic beantalk上路由www.domain.com-> domain.com(适用于chrome,但不适用于Safari) - HTTPS and route www.domain.com -> domain.com on AWS elastic beanstalk (works with chrome, but not safari) domain.com可以使用,但www.domain.com不能在Amazon EC2上使用 - domain.com works but www.domain.com doesn't work on amazon ec2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM