gpt4 book ai didi

ubuntu - nginx - 绑定(bind)()到 0.0.0.0 :80 failed (98: Address already in use)

转载 作者:行者123 更新时间:2023-12-04 18:26:28 24 4
gpt4 key购买 nike

我有一个设置了 5 个服务器配置的反向代理,但是从一开始它就一直提示无法监听我指定的端口,因此服务器无法启动。

我已经尝试了一些事情:

  • 将配置拆分为 sites-available 中的多个文件,并创建指向 sites-enabled 的符号链接(symbolic link)
  • 删除 listen 属性并允许其回退到默认值
  • 将端口更改为 ipv6only=on - 这导致了错误
  • 将端口更改为 [::]:80
  • 更改端口以免发生冲突,即 808182 等。

使用 netstat 我可以看到我需要的端口上没有运行任何东西,当我运行 nginx -t 时我得到一个成功的输出,说 syntax is ok and nginx .conf 测试成功。

这是我的 nginx 输出:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:81 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:82 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:83 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:84 failed (98: Address already in use)

有人知道这是为什么造成的吗?提前致谢

这是我的服务器配置:

server {
listen 80;
server_name hac-staging-proxy.redant.cloud;

location / {
proxy_pass http://195.219.8.212/;
proxy_set_header Host www.uat2prd.halfordsautocentres.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
}
}

server {
listen 81;
server_name halfords-c1-staging-proxy.redant.cloud;

location / {
proxy_pass http://195.219.8.206/;
proxy_set_header Host www.c1.uat2prd.halfordsautocentres.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
}

}

server {
listen 82;
server_name halfords-c2-staging-proxy.redant.cloud;

location / {
proxy_pass http://195.219.8.206/;
proxy_set_header Host www.c2.uat2prd.halfordsautocentres.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
}

}

server {
listen 83;
server_name halfords-staging-proxy.redant.cloud;

proxy_redirect http://www.uat2prd.halfords.com http://halfords-staging-proxy.redant.cloud;
proxy_redirect https://www.uat2prd.halfords.com https://halfords-staging-proxy.redant.cloud;

location / {
add_header Set-Cookie Experiment=FH;
resolver 127.0.0.1;
proxy_pass http://www.uat2prd.halfords.com;
# sub_filter_types *;
sub_filter 'www.uat2prd.halfords.com' 'halfords-staging-proxy.redant.cloud';
sub_filter 'www.c1.uat2prd.halfords.com' 'halfords-c1-staging-proxy.redant.cloud';
sub_filter 'www.c2.uat2prd.halfords.com' 'halfords-c2-staging-proxy.redant.cloud';
sub_filter_once off;
proxy_set_header Set-Cookie Experiment=FH;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
}
}

server {
listen 84;
server_name halfords-staging-proxy.redant.cloud2;

proxy_redirect https://www.uat2prd.halfords.com https://halfords-staging-proxy.redant.cloud;
proxy_redirect http://www.uat2prd.halfords.com http://halfords-staging-proxy.redant.cloud;

ssl_certificate /etc/nginx/domain.cert;
ssl_certificate_key /etc/nginx/domain.key;
ssl_dhparam /etc/ssl/certs/dhparam.pem;

ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "INTENTIONALLY REMOVED"
ssl_prefer_server_ciphers on;

location / {
add_header Set-Cookie Experiment=FH;
resolver 127.0.0.1;
proxy_pass https://www.uat2prd.halfords.com;
# proxy_ssl_session_reuse off;
# sub_filter_types *;
sub_filter 'www.uat2prd.halfords.com' 'halfords-staging-proxy.redant.cloud';
sub_filter 'www.c1.uat2prd.halfords.com' 'halfords-c1-staging-proxy.redant.cloud';
sub_filter 'www.c2.uat2prd.halfords.com' 'halfords-c2-staging-proxy.redant.cloud';
sub_filter_once off;
proxy_set_header Set-Cookie Experiment=FH;
proxy_set_header Host www.uat2prd.halfords.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
}
}

最佳答案

可能有nginx需要的端口,检查并打开它。它可能会起作用。或者只是扫描 nginx 目录中的所有文件以查找端口 98 它必须与 nginx 配置有关。

关于ubuntu - nginx - 绑定(bind)()到 0.0.0.0 :80 failed (98: Address already in use),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47073410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com