本文共 842 字,大约阅读时间需要 2 分钟。
1. 学习测试阶段,未避免破坏 nginx原有的配置文件,可在与 nginx.conf 同目录下创建一个新的文件----proxy.
proxy 文件内容如下:
server { listen 8099; server_name localhost; location / { #请求的主机域名; # proxy_set_header Host $host; #转的目标IP; # proxy_set_header X-Real-IP $remote_addr; #转发的目标 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #禁止缓冲 proxy_buffering off; proxy_pass http://192.168.2.3/guide_query.action; # http://www.baidu.com; # 只保留此句足以,访问内部服务器更直观明显,写百度之类的网址也可 } }2. 把proxy 文件与 nginx.conf文件关联到一起。
即 在nginx.conf 中的 http 节点下添加一句:
include proxy;部分 nginx.conf 文件,如下:
events { worker_connections 1024;}http { include proxy; include mime.types; default_type application/octet-stream;3. 重新启动 nginx 服务
在浏览器地址栏中输入:
http://localhost:8099/即可。
转载地址:http://qffob.baihongyu.com/