2

I need to proxy some remote api https://example.com/api/

to be accessible locally as http://localhost/api/

I tried putting this line in httpd.conf:

 ProxyPass     /api/     https://example.com/api/

I have checked these modules are enabled:

 ssl_module, proxy_module, proxy_http_module  

When I'm trying to reach http://localhost/api/, I'm getting 500 Internal Server Error, And what I see in error_log is:

[Wed Jan 14 16:42:04.788401 2015] [proxy:warn] [pid 21916] [client ::1:59260] AH01144: No protocol handler was valid for the URL /api/v1/ads. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.  

My question is relative to this one: https://stackoverflow.com/questions/1997001/setting-up-a-basic-web-proxy-in-apache. Actually, when I try to proxy http resources, everything works for me, so the problem is somewhere around SSL.

The reason I want this to work is the Access-Control-Allow-Origin problem I'm experiencing when working with remote api locally.


UPDATE

Here's the entire conf file. https://www.dropbox.com/s/mkrxna4h2o9yu8k/httpd.conf?dl=0

1

1 Answer 1

1

This should be all you need:

RewriteEngine On
RewriteRule ^/api/(.*)$ https://example.com/api/$1 [P,QSA,L]

Apache will basically proxy your requests by creating new http requests via the mod_rewrite module, which is enabled by default

4
  • Thank you for trying to help! I've uploaded the entire conf file and attached it to the question. Btw, after applying your answer, I get the following in error_log: [ssl:error] [pid 22221] [remote 54.149.6.238:443] AH01961: SSL Proxy requested for macs-MacBook-Pro.local:80 but not enabled [Hint: SSLProxyEngine] [Wed Jan 14 17:49:37.661756 2015] [proxy:error] [pid 22221] AH00961: HTTPS: failed to enable ssl support for 54.149.6.238:443 (api-staging.ad-rapid.com)
    – Dan
    Jan 14, 2015 at 16:59
  • Plus check if rewrite_module module is on, I suggest
    – Dan
    Jan 14, 2015 at 17:16
  • 2
    Make sure you have this too: "SSLProxyEngine on". Jan 14, 2015 at 19:14
  • And that worked!
    – Dan
    Jan 15, 2015 at 10:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .