Home > Backend Development > PHP Tutorial > Load balancing - nginx php parsing

Load balancing - nginx php parsing

WBOY
Release: 2016-07-06 13:53:23
Original
1115 people have browsed it

I used a virtual machine to set up two servers, one as an nginx load balancing server, one as a web server, and PHP as the background language. When I configure server_name in the nginx configuration file of the web server, when I directly access the web server IP address, I can parse the php file, but when I access the load balancing server, only the default page of nginx is displayed; when I do not configure server_name, which one is accessed? Only the nginx default page is displayed. What I want is to be able to parse php no matter which address is accessed. Solve Load balancing - nginx php parsing

Reply content:

I used a virtual machine to set up two servers, one as an nginx load balancing server, one as a web server, and PHP as the background language. When I configure server_name in the nginx configuration file of the web server, when I directly access the web server IP address, I can parse the php file, but when I access the load balancing server, only the default page of nginx is displayed; when I do not configure server_name, which one is accessed? Only the nginx default page is displayed. What I want is to be able to parse php no matter which address is accessed. Solve Load balancing - nginx php parsing

server_name *
Try this, it will adapt to all domain names

Is this Ng configuration forwarding PHP requests to the local port 9000? Try using upstream to transfer the request to the backend web server. Your description says there are two servers

It has nothing to do with server_name.
My load balancing is based on the following method

<code>upstream backend {
    server backend1.example.com       weight=5;
    server backend2.example.com:8080;
    server unix:/tmp/backend3;

    server backup1.example.com:8080   backup;
    server backup2.example.com:8080   backup;
}

server {
    location / {
        proxy_pass http://backend;
    }
}
</code>
Copy after login

The servers of backend1.example.com can be deployed as stand-alone machines

The questioner should first go to the nginx official website to see how to configure the upstream shunt module instructions to achieve load balancing. If you have any questions, please refer to the official documentation.

Where is your load balancing? Post the code so that everyone can know where you are wrong.

Related labels:
source:php.cn
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