nginx 反向代理使用简介

下载

地址:http://nginx.org/en/download.html  ,使用稳定版本 我使用的是1.14.2,下载解压后如下图所示:

nginx 使用

1.双击 nginx.exe 文件,黑色弹框一闪而过,即启动

2.使用cmd命令窗口,在nginx解压目录下,输入命令 nginx.exe 或者 start nginx

在浏览器中输入 localhost:80 ,出现如下图所示即启动成功

如启动不成功,可以修改 conf 目录中 nginx.conf 文件中:

1 server {
2         listen       8081;    修改端口号
3         server_name  localhost;

使用 localhost:8081 访问。

使用 nginx -s stop  或  nginx -s quit 停止 nginx。

配置反向代理或者负载平衡

 1 upstream my-server{
 2         server localhost:8080 weight=2;
 3         server localhost:10 weight=1;
 4     }
 5     server {
 6         listen       8081;
 7         server_name  localhost;
 8 
 9         location / {
10             proxy_pass http://my-server;
11         }

猜你喜欢

转载自www.cnblogs.com/amy2017/p/10357006.html
今日推荐