Windows Server使用Nginx反向代理获取404

时间:2019-09-10 21:46:37

标签: nginx nginx-reverse-proxy

我有一个Windows服务器,用于托管投资组合网站和某些应用程序,该网站使用nginx在端口80和443上工作。

我正在尝试让nginx反向代理我的一些应用程序,以帮助保护它们的安全。

按照所有指南操作后,我的网站仍可正常运行,但仍只能通过其分配的端口访问这些应用程序。

SSL nginx当前看起来像:

 server {
    listen       192.168.0.2:443;
    server_name  example.com 192.168.0.2;

    ssl_certificate      cert.pem;
    ssl_certificate_key  key.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    location / {
        root   html;
        index  index.php index.html index.htm;
    }

    location /app1/ {
        proxy_set_header Host 192.168.0.2:3882/;
        proxy_pass http://192.168.0.2:3882/app1;
    }

    location /app2 {
        proxy_pass http://127.0.0.1:3883;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

我尝试了两种不同的方法来尝试查看应用程序,但是两种方法均会产生404错误,错误日志显示以下错误:

2019/09/10 22:21:08 [error] 11940#15356: *1 CreateFile() "C:\Users\Alex\Services\nginx-1.17.3/html/app1" failed (2: The system cannot find the file specified), client: 192.168.0.2, server: example.com, request: "GET /app1 HTTP/1.1", host: "192.168.0.2"

从该错误中我可以得出的结论是,nginx在网站文件夹中查找,而不是在该应用程序的服务器中查找,因为我看不到该端口的引用。

我认为错误在某处:

location /app2 { proxy_pass http://127.0.0.1:3883;

该位置可能需要更多信息

0 个答案:

没有答案
相关问题