首页 > 解决方案 > 如何设置 nginx 将请求代理到我的 Web 应用程序?

问题描述

我需要如何配置我的 nginx 以代理对我的应用程序的请求?如果我的(前端)应用程序在 10.10.10.10:9999 地址上运行,并且我想在浏览器中使用 访问它myapplication.com,那么正确的配置是什么?

我现在有这些,但似乎不起作用:

worker_processes auto;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    
    server {
        listen 80;
        server_name myapplication.com;

        location / {

            proxy_set_header    x-real-IP $remote_addr;
            proxy_set_header    x-forwarded-for $proxy_add_x_forwarded_for;
            proxy_set_header    host $host;
            proxy_pass          http://10.10.10.10:9999;
        }


        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

标签: nginx

解决方案


推荐阅读