nginx 反代理端口报错

新手上路,请多包涵

添加

[root@localhost conf.d]# vi corenet.conf
server
{
listen 80;
server_name www.liangzda.com;
location /{
proxy_pass http://localhost:5000;
}
}
执行

[root@localhost conf.d]# nginx -s reload
[root@localhost conf.d]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx .service" and "journalctl -xe" for details.

详细错误如下
[root@localhost conf.d]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 二 2018-04-10 20:31:27 CST; 43s ago
Process: 2816 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 2813 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 2811 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)

4月 10 20:31:25 localhost.localdomain nginx[2816]: nginx: [emerg] bind() to [::]:80 failed (98: Address al...use)
4月 10 20:31:26 localhost.localdomain nginx[2816]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address...use)
4月 10 20:31:26 localhost.localdomain nginx[2816]: nginx: [emerg] bind() to [::]:80 failed (98: Address al...use)
4月 10 20:31:26 localhost.localdomain nginx[2816]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address...use)
4月 10 20:31:26 localhost.localdomain nginx[2816]: nginx: [emerg] bind() to [::]:80 failed (98: Address al...use)
4月 10 20:31:27 localhost.localdomain nginx[2816]: nginx: [emerg] still could not bind()
4月 10 20:31:27 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
4月 10 20:31:27 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
4月 10 20:31:27 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
4月 10 20:31:27 localhost.localdomain systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

阅读 4.8k
1 个回答

端口被占用,应该是你已经启了 nginx,或者有其他程序占用了 80 端口

你可以用 ss -lntp | egrep ':80\s' 来看看到底是什么程序在占用 80 端口

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题