node.js - 在端口 8080 上向本地服务器发出请求
问题描述
我现在有以下流程。
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 中工作。
解决方案
推荐阅读
- python - Visual Studio Code 中出现问题
- python - 如何就地获取数组中项目的出现次数
- python - “for”循环未正确循环
- javascript - 反应:用数组信息按列填充表格
- go - Sql.Open 全局连接的最佳方法
- java - Spring Boot 多数据源设置
- javascript - 在 javascript 中执行 asnyc 方法的传统方式
- python - 当模型具有相同的字段但不同的 help_text 时,在 django 中是否可以继承
- angular - 在不重新创建整个对象的情况下更改对象数组的属性值
- sql - 使用 %TYPE oracle 更改表添加列