nginx配置用于EC2。

huangapple go评论57阅读模式
英文:

nginx configuration for ec2

问题

请使用"Public IPv4 address"在您的服务器块中。您的服务器块应如下所示:

server {
    listen 公共IPv4地址:80 default_server;

这样配置后,您的应用将能够在EC2实例上本地运行,并能够响应来自外部计算机的请求。

英文:

I have an app on nginx which works fine when I run things locally via curl but does not seem to like it when i try it from an external computer.

On EC2 console I see three different types of ip addresses:

Public IPv4 address, Private IPv4 addresses, Public IPv4 DNS

which one should be on the server block? My server block looks like so:

server {
    listen xx-xx-xx-xxx:80 default_server;

When I use the following on nginx server block, I have the following:

private IP address: app works locally on ec2 (responds correctly to curl requests) but does not respond on external requests (curl)
public IP address: nginx fails with:

May 11 08:55:59 ip-xx-xx-xx-xxx nginx[1936]: nginx: [emerg] bind() to xx-xx-xx-xxx:80 failed (99: Cannot assign requested address)

Public IPv4 DNS: app works locally (curl responds correctly), but does not work externally

WTF should I be using on the server block. so confusing!

答案1

得分: 0

你应该使用公共IP地址,并确保80端口是否被允许。

英文:

You should use public IP address and have to make sure that whether 80 port is allowed or not

huangapple
  • 本文由 发表于 2023年5月11日 17:33:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76226169.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定