curl可以工作,但是nginx反向代理不起作用

时间:2019-04-05 19:11:49

标签: nginx curl http-status-code-404 reverse-proxy

到代理服务器的卷发有效,但是当我尝试通过nginx反向代理使其工作时,甚至没有请求到达另一台服务器。

这是我的卷发,


Below is my nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log debug;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       9001 default_server;
        listen       [::]:9001 default_server;
        server_name  _;
    ssl on;
    ssl_certificate /etc/nginx/ssl/ca.crt;
    ssl_certificate_key /etc/nginx/ssl/ca.key;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

#   root /;

    location / {

        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host example-proxy.yola.com;
        proxy_pass https://example-proxy.yola.com:443;
        include /etc/nginx/role-token;
    }
    }

    server {
    listen 9002 default_server;
    server_name _;
    location / {

    root /;
    }
    }
}

在尝试

curl -d@test.xml -k https://localhost:9001/bio/V2/moderate?appId=ronga -vvv

它抛出以下错误

* About to connect() to localhost port 9001 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 9001 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* skipping SSL peer certificate verification
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
*   subject: O=Default Company Ltd,L=Default City,C=US
*   start date: Mar 28 22:08:28 2019 GMT
*   expire date: Apr 27 22:08:28 2019 GMT
*   common name: (nil)
*   issuer: O=Default Company Ltd,L=Default City,C=US
> POST /bio/V2/moderate?appId=ronga HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:9001
> Accept: */*
> Content-Length: 322
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 322 out of 322 bytes
< HTTP/1.1 404 Not Found on Accelerator
< Server: nginx/1.12.2
< Date: Fri, 05 Apr 2019 19:05:39 GMT
< Content-Type: text/html
< Content-Length: 2876
< Connection: keep-alive
< Cache-Control: no-store
< Content-Language: en

我尝试在proxy_pass的末尾添加斜杠,还尝试将完整的url路径添加到proxy_pass,但没有一个起作用。另外,我还没有在Nginx错误或访问日志上看到任何内容。我真的很感谢有人可以提出建议。

0 个答案:

没有答案