linux - 一台 Linux 服务器中的 nginx 2 服务器 block

标签 linux nginx

我无法重新启动 nginx,因为我收到 [emerg] 6594#6594: bind() to 0.0.0.0:443 failed (98: Address already in use)。多服务器 block 如何工作?如果没有临时服务器 block ,我的配置工作正常。

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name api.example.com;

    location / {
        proxy_pass http://localhost:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

server {
    listen 443;

    server_name staging-api.example.com;

    location / {
        proxy_pass http://localhost:3002;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

最佳答案

netstat -anp | grep :443 chgeck哪个应用程序接管了443端口,如果不需要,杀死它然后重新启动nginx

关于linux - 一台 Linux 服务器中的 nginx 2 服务器 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52569558/

相关文章:

r - Linux 服务器在 R 并行中崩溃 - 反序列化错误(节点 $con): error reading from connection

c - 如何在干净的环境中从 C 调用 bash?

nginx - 推荐的 CORS 允许和公开 header

javascript - 在 Nginx 或 Django 中安装 Prerender?

web-services - 在生产环境中部署 Go/Golang REST Web API

linux - 以下命令的作用是什么?

linux - 获取命令输出重定向到的路径

php - 阻塞方法如fcntl()和accept(),请求者中哪一个会得到它?

Nginx 可以 ping 自己,但无法从其他任何地方连接

linux - 为什么我预定的工作没有完成?