http - Nginx 正在运行但未提供服务

标签 http nginx

我正在为端口 9001 的所有 HTTP 流量配置代理传递。

Nginx.conf

#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

#include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    include /etc/nginx/sites-enabled/*;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

  #include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

可用站点/itdb:

server {
    listen 80;
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:9001/;
    }
}
  • 我已验证 sites-availablesites-enabled 之间的符号链接(symbolic link)完好无损并识别我的配置。
  • 我没有收到任何错误,并且所有 nginx-t 测试 都成功成功。
  • 我尝试过在代理传递中使用或不使用尾随/。

我有点迷失了还要寻找什么。有什么事情让你印象深刻吗?

最佳答案

您可以验证 nginx 是否正在运行并绑定(bind)到端口 80,如 lsof和/或fstat :

这是 OpenBSD 上的 fstat:

% fstat -u www | fgrep "*:"
www      nginx      21404   82* internet stream tcp 0xfffffe833a10d250 *:80
www      nginx      21404   83* internet6 stream tcp 0xfffffe833a10d480 *:80

这是 GNU/Linux 上的 lsof:

% lsof -i -n | fgrep nginx
nginx    24854        root    6u  IPv4 61955031      0t0  TCP *:http (LISTEN)
nginx    25047      nobody    6u  IPv4 61955031      0t0  TCP *:http (LISTEN)

此外,根据https://serverfault.com/a/870709/110020 ,我建议不要使用 sites-available/sites-enabled,因为它也可能会给您带来额外的麻烦。

下一步是运行 curl -v从运行 nginx 的盒子内,和/或涉及 tcpdump尝试找出数据包丢失的位置 - 也许您有防火墙?你收到 nginx 的回复了吗?也许是您的后端不可用?

关于http - Nginx 正在运行但未提供服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54701110/

相关文章:

json - 使用 R 发布 JSON

http - 如何使用ADAL Objective-C提取从Azure AD发送的HTTP错误代码

node.js - 使用 Express.js 的多个 SSL 证书和 HTTP/2

python - 在 uwsgi 上切换 python 版本

nginx - kubectl port-forward 不适用于 EC2 实例

NGINX 在 60 秒内关闭上游连接

http - 如何查看 HTTP/HTTPS 与 HTTP 客户端的交互

django - 为什么 Web 框架通过 FastCGI/SCGI 而不是 HTTP 提供服务?

具有长查询字符串参数的 ASP.NET 处理程序 (.ashx)

nginx - 如何在 Gitlab Omnibus 服务器旁边为其他虚拟主机提供服务? [完整的逐步解决方案]