nginx 反向代理的配置

nginx中的每个server就是一个反向代理配置,可以有多个server(nginx只能处理静态资源)

nginx 反向代理的配置_第1张图片

 

 

 nginx中 server的配置

 

server {
  listen 80;
  server_name manage.leyou.com;

  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

  location / {  # / 代表一切路径
    proxy_pass http://127.0.0.1:9001;  # 一切通过  manage.leyou.com/ ....   或者   manage.leyou.com:80/ .... 的请求 都会被代理到
    proxy_connect_timeout 600;      #127.0.0.1:9001
    proxy_read_timeout 600;
  }
}
server {
  listen 80;
  server_name api.leyou.com;

  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

  location / {
    proxy_pass http://127.0.0.1:10010;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
  }
}

你可能感兴趣的:(nginx 反向代理的配置)