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

What to do with nginx reverse proxy

王林
Release: 2023-05-29 11:19:11
forward
1031 people have browsed it

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;
        }
}
Copy after login
  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;
        }
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template