Basic questions about nginx reverse proxy server configuration? I am a newbie, please give me some advice, thank you very much...
怪我咯
怪我咯 2017-05-16 17:15:08
0
4
575

The company has a reverse proxy server, nginx.conf configuration file, the key parts are configured as follows:

    server {
        listen       8077;
        server_name  localhost:9000;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location  /front/ {
            proxy_pass  http://127.0.0.1:9000/;
        }
        location  /services/ {
            proxy_pass  http://127.0.0.1:8080/services/;
        }

Question 1: Could you please use a voice that novices can understand and explain what the four places marked by arrows mean?
Question 2: listen The default port is 80, which has been changed to 8077 above. If it is changed to 80, you can use the following link to access the reverse proxy (the effect I want)

http://localhost/front/#/main/home     这种方法来访问
http://localhost/front/      测试服务器地址

However, the port is now changed to 8077. How can I rewrite the above two URLs to achieve the same effect as port 80?

I am a novice, please give me some advice, thank you very much...

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(4)
PHPzhong

Arrow 1
Listen to the local port 8077
Arrow two
There is no such way of writing
Arrow three
There is front in the access path,
Arrow four
Reverse proxy to the local port 9000, this should be the php-fpm listening port
If Need to be changed to 8077
Arrow 2 should be changed to

server_name localhost;

Open the browser http://localhost:8077/front/

仅有的幸福

It’s not like I can give you any advice. I can only give you a rough idea. I know the specifics very well.

  1. listen 8077 means that if the port accessed by the user is 8077, use this configuration (nginx listens to port 8077)

  2. If only one server domain is configured in nginx, nginx will not match the server_name. Because there is only one server domain, that is, there is one virtual host, then all requests sent to the nginx must be forwarded to this domain, and even a single match is useless. It's better to just skip it. If there are multiple server domains for an http domain, nginx will match the server_name based on $hostname and then forward the request to the matching server domain

  3. The next step is the path matching rule. If the path is /front/, then the request will be forwarded (reverse proxy to) the service at http://127.0.0.1:9000, so that the service listening on port 9000 can receive the request.

Question: I don’t know the difference between "/front/" and "/front". I hope someone can answer it

I think this configuration is used to separate the front and rear ends. Separate interface requests and front-end requests.

刘奇

For this kind of problem, it’s better to check the nginx configuration file online first. If you don’t understand it, come back and ask questions.

某草草

Create multiple server configuration files immediately

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template