栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Nginx开发常见问题(持续更新中)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Nginx开发常见问题(持续更新中)

1、nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)问题的解决

(1)问题现状

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

(2)问题原因

80端口已经被占用

(3)解决方案

查询端口是否被占用 :netstat -nlput | grep 80

查询占用端口的进程 : lsof -i :80

杀死进程 : kill -9 33877,kill -9 33878

之后启动服务即可 2、Nginx启动失败

(1)问题现状

http://hadoop102:80

(2)问题原因定位

查看nginx的log文件下的error.log日志

本人原因(nginx代理端口与springboot端口配置不一致)

2022/01/18 11:18:59 [error] 105361#0: *5 connect() failed (111: Connection refused) while connecting to upstream, clie
nt: 192.168.6.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://192.168.6.104:8081/", host: "hadoop10
2"
2022/01/18 11:18:59 [error] 105361#0: *5 connect() failed (111: Connection refused) while connecting to upstream, clie
nt: 192.168.6.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://192.168.6.103:8081/", host: "hadoop10
2"
2022/01/18 11:18:59 [error] 105361#0: *5 connect() failed (111: Connection refused) while connecting to upstream, clie
nt: 192.168.6.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://192.168.6.102:8081/", host: "hadoop10
2"
2022/01/18 11:18:59 [error] 105361#0: *5 no live upstreams while connecting to upstream, client: 192.168.6.1, server: 
localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://logcluster/favicon.ico", host: "hadoop102", referre
r: "http://hadoop102/

(3)解决方案

打开配置文件,

cd /opt/module/nginx/conf

vim nginx.conf

修改如下配置

http{   #gzip  on;
    #配置代理服务器
    upstream logcluster{
        server hadoop102:8081 weight=1;
        server hadoop103:8081 weight=1;
        server hadoop104:8081 weight=1;
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;
            #index  index.html index.htm;
            #代理的服务器集群,命名随意,但是不能出现下划线
            proxy_pass http://logcluster;
            proxy_connect_timeout 10;
        }
......
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/709438.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号