Nginx使用部署方案

Nginx 是一个高性能的 HTTP 和 反向代理 web服务器,运行在各种平台上(Windows,Linux,Unix,Mac OS X等)。
1.Nginx下载地址:http://nginx.org/en/download.html 下载windows版本,解压即可(这里我下载的是最新稳定版1.20.2)

 

 2.cmd到安装目录,执行命令  start nginx.exe (有个窗口一闪而过)

查看任务管理器中有nginx服务表示启动成功

 

 3.目前的需求是,使用一个对外的端口代理两个项目,达到都可以访问的目的

简单配置一下:

 1     server {
 2         listen       8080;
 3         server_name  localhost;
 4 
 5         #charset koi8-r;
 6 
 7         #access_log  logs/host.access.log  main;
 8 
 9         location / {
10             root   html;
11             index  index.html index.htm;
12         }
13 
14     location /web1/ {
15             proxy_pass http://localhost:8081/;
16         }
17 
18         location  /web2/ {
19            proxy_pass http://localhost:8082/;
20        }

此时我们访问  http://localhost:8080/web1 相当于  http://localhost:8081
访问  http://localhost:8080/web2 相当于  http://localhost:8082

posted @ 2022-03-04 22:15  atimo  阅读(126)  评论(0编辑  收藏  举报