在端口8080

时间:2019-01-17 13:17:35

标签: node.js http nginx server request

我现在有以下流程。

example.com => https://example-example.mycompany.com => myproxy => someServer

我现在正在开发myproxy,它更改了网站example.com的客户正在接收的答案。

为了对此进行测试,我认为我能想到的最好的主意是更改本地计算机(在该计算机中,我的myproxy实例在端口8080上运行),所以我仅将我对example-example.mycompany.com的请求重定向到localhost:8080

我尝试nginx添加以下配置,但是我无法...而且更改/etc/hosts并没有帮助我。

问题

是否可以更改计算机上example-example.mycompany.com Just 的呼叫,因此在测试时,example.com的客户端不会受到任何影响本地myproxy中的更改?

试用

  • 创建一个在8080和80中运行的docker容器,并尝试针对它进行请求

docker run --name my-custom-nginx-container -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro -p 80:80 -p 3000:8080 --rm -d nginx

  • 创建一个nginx服务器(因此我对容器没有问题,可能无法正确绑定)

nginx.conf

server {
            listen   80;
            server_name example-example.mycompany.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_set_header X-NginX-Proxy true;
                    proxy_pass http://localhost:3000/;
                    proxy_redirect http://localhost:3000/ https://$server_name/;
            }
    }
  • 将example-example.mycompany.com添加到etc / hosts文件中(没有做任何事情)

/etc/hosts

127.0.0.1 example-example.mycompany.com

注意::我已经看到它可以在使用Windows的同事的计算机上工作。我无法在Linux / MacOs中使用它。

0 个答案:

没有答案
相关问题