使用Nginx的反向代理

我想将反向代理与nginx一起使用,以将IP和端口重定向/转换为其他IP和端口。我能够在nginx.conf的http块内使用以下代码段来做到这一点:

 server {
    listen       80;
    server_name  13.88.1.1;

    location / {
        proxy_pass http://13.68.1.1:8888/;
        index  index.html index.htm;
        } # end location
    } # end server

现在的问题是,这仅可用于http请求。我有一种情况,需要运行“ uw.exe 13.88.1.1:80”之类的可执行文件。这将被翻译为“ uw.exe http://13.68.1.1:8888”,但我希望将其翻译为“ uw.exe 13.68.1.1:8888”。那没有http,因为我的应用程序无法与http一起使用。是否有人知道有任何简单的解决方案,最好是使用nginx本身?

zhangziqun31 回答:使用Nginx的反向代理

试试这个 nginx 配置:

server {
    listen       80;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Connection '';
        proxy_redirect off;
        proxy_pass http://13.88.1.1:8888/;
    }
}
本文链接:https://www.f2er.com/3083448.html

大家都在问