Proxying http requests?

Posted on 2010-01-03
Last Modified: 2012-05-08

I'm working on a javascript project. My script has to access a php file on my remote server.

So the javascript file is running locally on my machine, the php script it wants to access is on the remote server, and I guess I run into the same origin policy problem because of that.

Is it possible to somehow have my script access a version of apache running locally, which then just proxies the request to my real remote web server? Ideally it would just take the requested URL, send it to my remote server, then respond with whatever data my remote server would have sent back anyway.

Question by:DJ_AM_Juicebox
    LVL 57

    Expert Comment

    You can setup Apache to be  a proxy server:


    Author Comment

    Ok that seems to be what I need. I'm on a max os 10.5 machine, so it's already running apache, I was able to verify that. I have the http.conf file here, am I supposed to add the proxy statements there?

    The example given in the page you linked:

      ProxyRequests On
      ProxyVia On

      <Proxy *>
        Order deny,allow
        Deny from all
        Allow from

    is that literally would be added to http.conf (although I would replace with ?

    LVL 15

    Accepted Solution


    to my understanding, the JS file would be executed on client browser, while the PHP would be executed on the Apache/server.

    to understand the scenario:

    >> I'm working on a javascript project. My script has to access a php file on my remote server.

    Hence, the original url :, would have some embedded hyperlink, in the format

    In order for the something.php to be executed, this url needs to be "loaded" by the client broser.  in other words, the client need to have access to the

    the mod_proxy (as commened by giltr) would be useful to enable the apache  on site1 to proxy the request to the apeche on server remote.

    how this could be achieved would depends on how the JS is coded.  what I could think of is, you have all the php on the remote server (lets use, and in the, have a reverse proxy setup to proxy the request for the php scripts.


    ProxyPass /scripts
    ProxyPassReverse /scripts

    and in you JS file; have the PHP loaded as

    I hope i am interpreting your intention correctly, and be of some help -- as oppose to confuse things..

    happy new year!


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now