Configuring the reverse proxy on Nginx and Apache servers

Source: Internet
Author: User
Tags website server

In the actual project process, because the website to use an online editor (personalized online editing software), need to communicate across the domain! Because the cross-domain communication is more, so at that time think of proxy editing software requests on the website server!

This is the actual demand of "reverse proxy"!

One, nginx configuration reverse Proxy

 location/edit/ {proxy_pass http://edit.host.net/;                #Proxy Settings  proxy_redirect off;                Proxy_set_header Host $host ;                Proxy_set_header x-real-ip $remote _addr ;                Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for ;                Proxy_set_header accept-encoding "";                Proxy_set_header X-nginx-proxy true; Proxy_http_version 1.1 ; Proxy_next_upstream error timeout Invalid_header http_500 http_502 http_503 http_504; 
Proxy_max_temp_file_size 0; proxy_connect_timeout; proxy_send_timeout; proxy_read_timeout 90; proxy_buffering off; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k;}

In the actual configuration process, found that the online editing software static resource files are not loaded (such as CSS, JS, pictures, etc.), and later found that the editor static resources are linked to the relative path! It was considered a path problem at the time,

The Proxy_pass domain name is appended with "/" to refer to the resource file from the root path! But the test found that there is still the same problem! After the last various attempts, the following lines of configuration files are found:

Location ~. *\. (gif|jpg|jpeg|png|bmp| swf) ${      ~. *\. ( JS|CSS)? ${       expires 1h;}    

Just a few lines above are configured to affect the proxy path of a static resource, resulting in a static resource not being loaded (404 error)!

Second, configure the reverse proxy on Apache

Configuring the reverse proxy in Apache is relatively straightforward, and directly post the configuration code:

<virtualhost *:80>DocumentRoot"D:\phpStudy\WWW\git Ecshop"ServerName http://local.shop.tuwen.comServeralias proxyrequests on rewriteengine off<proxy *>Order deny, allow to from all</Proxy>Proxypass/edit http://edit.host.net/Proxypassreverse/edit http://edit.host.net/<directory "D:\phpStudy\WWW\git ecshop" >Options followsymlinks execcgi allowoverride all Order allow,deny allow from allRequireAll granted</Directory></VirtualHost>

Of course, the corresponding server support reverse proxy module needs to open Oh! This must not forget!

Configuring the reverse proxy on Nginx and Apache servers

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.