Nginx reverse proxy and load balancer

Source: Internet
Author: User

Install Nginx and Apache on a single machine

In/etc/hosts

192.168.200.156 www.a.com #本机ip

127.0.0.1 www.shenge1.com


Nginx Domain Name: www.a.com (port default 80)

Apache Domain name: www.shenge1.com (the default port of 80 is 8080)

In the Nginx configuration file

http{

...

Upstream backend{#这里配置上游服务器的地址 (This example refers to the Apache server)

Server www.shenge1.com:8080;

...

}

server{

Listen 80;

server_name www.a.com;

Location/{

root/www/www.a.com;

Index index.html;

}

...

Location ~\.php$ {#匹配. php file, which is based on the/etc/httpd/conf/httpd.conf configuration file

#DocumentRoot "/var/www/html" to/var/www/html as an Apache resource

#跟目录, PHP and other files placed in this directory is good.


Proxy_pass Http://backend; #这里设置上游服务器 (actually backend refers to a bunch of server addresses)

}

}

..


}


Apache/etc/httpd/conf/httpd.conf

Listen 8080


The index.html content under the/www/www.a.com/(Nginx server Resource) is

Nginx


/var/www/html/(Resources of Apache server) the index.php content is

<?php>

Phpinfo ()

<?>



Open Nginx

Nginx

Open Apache

Service httpd Start


The individual nginx can only parse the static interface (that is, HTML files), and Apache has a PHP module to

Parse PHP file, genetic a lot of static HTML interface, then return to Nginx, and then return to the client browser

First access in the browser www.a.com appears the interface display Nginx Normal startup

Then www.a.com/index.php, if only the individual nginx is unable to display

Out, if according to our configuration will nginx as a reverse proxy through Apache can parse, at this time

If it can resolve, the reverse proxy is not a problem.


This article is from the "12208412" blog, please be sure to keep this source http://12218412.blog.51cto.com/12208412/1866825

Nginx reverse proxy and load balancer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.