For some reasons I need to access https://api.postcodeapi.nu/ with http instead of https. I have created a reverse proxy in my Apache:

ServerName api.postcodeapi.nu.local
SSLProxyEngine on
ProxyPass / https://api.postcodeapi.nu/
ProxyPassReverse / https://api.postcodeapi.nu/

Added following line in /etc/hosts      api.postcodeapi.nu.local

and accessing with curl but get Bad gateway:

# curl http://api.postcodeapi.nu.local
<title>502 Bad Gateway</title>
<h1>Bad Gateway</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />

Can someone please help me?

  • 1
    Is there anything in the Apache error logs? – Lacek May 24 '18 at 10:31
  • Since curl https://api.postcodeapi.nu/ also generates an error response it is not surprising that making that same request via your reverse proxy also results in an error. – HBruijn May 24 '18 at 11:43
  • curl api.postcodeapi.nu doesn't get bad gateway error but gets following: {"message":"Forbidden"} which is perfectly fine – Zulqarnain Habib May 24 '18 at 19:02
  • Apache logs say [Thu May 24 15:03:35 2018] [error] (502)Unknown error 502: proxy: pass request body failed to (api.postcodeapi.nu) [Thu May 24 15:03:35 2018] [error] proxy: pass request body failed to (api.postcodeapi.nu) from () – Zulqarnain Habib May 24 '18 at 19:04
  • Any help please? – Zulqarnain Habib May 25 '18 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.