Home >Operation and Maintenance >Nginx >What to do with nginx reverse proxy

What to do with nginx reverse proxy

王林
王林forward
2023-05-29 11:19:111034browse

1. Composition of nginx configuration file

nginx consists of the following parts

What to do with nginx reverse proxy

2. Use of nginx reverse proxy

The proxy_pass directive can proxy to the URL address after proxy_pass according to the rules

What to do with nginx reverse proxy

server_name is used to define which URLs use this rule
Proxy all requests under gulimaill.com

The load balancing syntax is as follows upstream is defined to use the load balancing server in the balancing server proxy_pass
You can use this method to proxy the gateway

http {
    upstream myapp1 {
        server srv1.example.com;
        server srv2.example.com;
        server srv3.example.com;
    }

    server {
        listen 80;
        location / {
            proxy_pass http://myapp1;
        }
}
  upstream gulimall {
        server 192.168.1.7:10001;
    }
        location / {
                proxy_set_header Host $host;
                # proxy_pass http://192.168.1.7:10000;
                proxy_pass http://gulimall;
        }

Then configure the gateway
When the url is ***.gulimaill If .com, jump to the product service

What to do with nginx reverse proxy

##There is a pitfall here because nginx does not carry the Host request header, so you have to add proxy_set_header Host $host; configuration

The above is the detailed content of What to do with nginx reverse proxy. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete