http - 如何启用nginx代理通行证?

标签 http web nginx proxy webserver

我有一个运行我的应用程序的内部服务器。此应用程序在端口 9001 上运行。我希望人们通过 nginx 访问此应用程序,它在 DMZ 网络上运行的 Ubuntu 机器上运行。

我已经使用 stickySSL 模块的选项从源代码构建了 nginx。它运行良好但不执行代理传递。

服务器外部 IP 的 DNS 名称是:bd.com.tr 我希望人们看到页面 http://bd .com.tr/public/control.xhtml 当他们输入 bd.com.tr 但即使强硬的 nginx 将根请求重定向到我想要的路径,应用程序也没有显示。

我的 nginx.conf 文件是:

worker_processes  4;
error_log  logs/error.log;

worker_rlimit_nofile 20480;

pid        logs/nginx.pid;

events {
    worker_connections  1900;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    server_tokens off;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    keepalive_timeout  75;

    rewrite_log on;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Ssl on;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_read_timeout      150;

    server  {

        listen 80;
        client_max_body_size 300M;

        location = / {
                rewrite ^ http://bd.com.tr/public/control.xhtml redirect;
         }

         location /public {
           proxy_pass http://BACKEND_IP:9001;
        }
    }

}

我可能遗漏了什么?

最佳答案

这是一个愚蠢的问题,我找到了。 conf 文件是正确的,因此您可以根据需要使用它,问题是; BACKEND_IP 的端口 9001 没有被转发,因此 nginx 无法到达内部服务。转发端口后,它工作正常。我在 error.log 中发现了问题,所以如果您遇到此类问题,请先检查错误日志:)

关于http - 如何启用nginx代理通行证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34637405/

相关文章:

http - www.domain.tld 与 domain.tld

http - 这里应该使用 401 Unauthorized 还是 403 Forbidden?

python - 读取在 ajax 中传递的自定义 header

jquery - .JS 拒绝启用菜单

nginx - IP允许子目录访问NGINX

php - Nginx - 提供没有扩展名的图像

lua - nginx proxy_pass 基于请求方法是 POST、PUT 还是 DELETE

python - 带有 python 套接字的 HTTP 服务器

http - 如何从 HTTP header 中获取客户端 IP 地址?

css - 如何将 svg 合并到 React 组件中?