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...
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
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.
listen 8077 means that if the port accessed by the user is 8077, use this configuration (nginx listens to port 8077)
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
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