Nginx Reverse proxy configuration Configuration instance

Source: Internet
Author: User
Tags nginx reverse proxy

In order to save money, the company needs to be distributed in different machine sites are migrated to a machine, and now different machines are running different Web services, part Nginx, part of Apache, because of the more rewrite rules involved, in order to save changes in Kung Fu, After the plan to migrate the site still use the original Web services, but the same machine 80 port can only be assigned to a Web service use, so the plan Nginx use 80,apache other ports such as 8088, through the Nginx reverse proxy, Enable Apache's site to jump from port 80 to port 8088.

1, Nginx and Apache installation process skipped

2, Nginx api.127.com site reverse Configuration
# Cat Api.127.com.conf

Upstream api.127.com {
Server 127.0.0.1:8088;
  }
server{
Listen;
server_name api.127.com;     
Location/{
Root/home/web/api.127.com/nginx_proxy;
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header x-real-ip $remote _addr;
Proxy_set_header remote-host $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
Client_max_body_size 50m;
Client_body_buffer_size 256k;
Proxy_connect_timeout 30;
Proxy_send_timeout 30;
Proxy_read_timeout 60;
Proxy_buffer_size 256k;
Proxy_buffers 4 256k;
Proxy_busy_buffers_size 256k;
Proxy_temp_file_write_size 256k;
Proxy_next_upstream Error Timeout invalid_header http_500 http_503 http_404;
Proxy_max_temp_file_size 128m;
Proxy_pass http://api.127.com;
}
}

3, Apache's api.127.com:8088 site configuration
<virtualhost *:8088>
ServerName api.127.com
Serveralias api.127.com
Documentroot/home/web/api.127.com
DirectoryIndex index.html index.htm index.php
Errorlog Logs/api.127.com_error_log
Customlog Logs/api.127.com_access_log combined

<Directory/home/web/api.127.com>
Options FollowSymLinks
AllowOverride All
Order Deny,allow
Allow from all
</Directory>

<directory ~ "^/home/web/api.127.com/(. +/) *\.SVN" >
Order Allow,deny
Deny from all
</Directory>

4, the effect of the final realization is that the browser opened the address api.127.com when the actual access to api.127.com:8088

Nginx Reverse proxy configuration Configuration instance

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.