Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a basic web proxy in apache

Tags:

I'm looking to run Apache as a proxy for web development. I'm running Mac OS X 10.5.4, which already has Apache 2.2.8 installed and running.

I'd like to point my JavaScript files (which are running locally on my machine) to:

http://localhost/test.php 

which would hit the local apache server, then have that apache instance forward to my real remote server:

http://www.mysite.com/test.php 

I've looked at a few walkthroughs but they seem to be out of date. I'm wondering if there's a recent how-to on setting this up - the doc here:

http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

gives a basic example, but I'm not sure where that text should be added - to http.conf? Do I simply add it there, then restart the server?

Thanks

like image 745
mark Avatar asked Jan 04 '10 00:01

mark


People also ask

Does Apache act as a proxy server?

In addition to being a "basic" web server, and providing static and dynamic content to end-users, Apache httpd (as well as most other web servers) can also act as a reverse proxy server, also-known-as a "gateway" server.

How does Apache support proxy?

Apache Working As A Reverse-Proxy Using mod_proxy Some of these modules are: mod_proxy: The main proxy module for Apache that manages connections and redirects them. mod_proxy_http: This module implements the proxy features for HTTP and HTTPS protocols. mod_proxy_ftp: This module does the same but for FTP protocol.

What is Apache HTTP proxy?

Apache HTTP Proxy is a proxy service that can be used to distribute updates to client computers. Apache HTTP Proxy performs a similar role to the mirror server feature popular in ERA 5 and earlier. To install Apache HTTP Proxy, read the instructions for Windows, Linux, or Virtual Appliance.


1 Answers

The proxy setup that you describe is called a Reverse Proxy.

This is very easy to set up in Apache, by using the mod_proxy module.

The fundamental mod_proxy directive to set up a reverse proxy is the ProxyPass. You would typically add the following line to your local Apache configuration file (usually httpd.conf or apache2.conf):

ProxyPass     /remote/     http://www.mysite.com/ 

In this case, the browser would be requesting http://localhost/remote/test.php but your local Apache server would serve this by acting as a proxy to http://www.mysite.com/test.php.

You also need to make sure to have the following configuration lines uncommented in your Apache config file:

LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so 

Make sure to restart your local Apache service after you do any changes to the config file.

like image 158
Daniel Vassallo Avatar answered Sep 19 '22 06:09

Daniel Vassallo