ngoni配置本地路径代理
时间: 2023-07-17 10:09:49 浏览: 44
您可以通过在Nginx配置文件中设置本地路径代理来实现。以下是一个示例配置:
```nginx
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:8000; # 将请求代理到本地的8000端口
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
```
在上述配置中,当有请求访问 `example.com` 时,Nginx会将请求代理到本地的 `http://localhost:8000`,并且会将原始的Host和IP信息传递给后端服务器。
请确保将 `example.com` 替换为您自己的域名或IP地址,并根据实际情况更改代理的目标地址和端口。
完成配置后,重新加载Nginx配置使其生效:
```shell
sudo systemctl reload nginx
```
这样,当有请求访问 `example.com` 时,Nginx会将请求代理到本地的指定端口。