美文网首页
nginx笔记

nginx笔记

作者: 我是电饭煲 | 来源:发表于2020-04-01 15:59 被阅读0次

引用子配置

  • 在主配置上添加

include /etc/nginx/conf.d/*.conf;

  • 创建子配置
cd /etc/nginx/conf.d
sudo touch xxx.conf
sudo vi xxx.conf

Nginx反向代理配置

# 编辑nginx配置文件,添加以下内容
# vim /usr/local/nginx/conf/nginx.conf

    upstream applications {
      server 192.168.68.43:8081 weight=1;
      server 192.168.68.45:8082 weight=1;
    }

    server {
          listen       80; # 代理端口
          server_name  localhost;

          location / {
              proxy_pass http://applications; #代理的端口
              proxy_set_header Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Real-Port $remote_port;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
      }

相关文章

网友评论

      本文标题:nginx笔记

      本文链接:https://www.haomeiwen.com/subject/dcnwdctx.html