1.我们首先需要配置hosts
windows 下hosts 的地址为 C:\Windows\System32\drivers\etc
我们需要在hosts文件里面添加如下配置
2.然后在 nginx 的 http 模块上添加一个 server
server {
#侦听80端口
listen 80;
server_name test.nginx.com;
#charset koi8-r;
#设定本虚拟主机的访问日志
#access_log logs/host.access.log main;
#默认请求
location / {
proxy_pass http://192.168.1.114:8080;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
3.然后重启nginx 在浏览器输入 test.nginx.com