1

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:

<VirtualHost 127.0.0.1:80>
ServerName api.postcodeapi.nu.local
SSLProxyEngine on
ProxyPass / https://api.postcodeapi.nu/
ProxyPassReverse / https://api.postcodeapi.nu/
</VirtualHost>

Added following line in /etc/hosts

127.0.0.1      api.postcodeapi.nu.local

and accessing with curl but get Bad gateway:

# curl http://api.postcodeapi.nu.local
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>502 Bad Gateway</title>
</head><body>
<h1>Bad Gateway</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
</p>
</body></html>

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 52.85.101.59:443 (api.postcodeapi.nu) [Thu May 24 15:03:35 2018] [error] proxy: pass request body failed to 52.85.101.59:443 (api.postcodeapi.nu) from 127.0.0.1 () – 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.