I have got some google cloud run service endpoints that are secured by HTTPS. I want to set up my apache webserver to reverse proxy into the services so that people using my defined URL get back the service response.
I have tried to use mod_proxy and mod_rewrite to proxy the service endpoint but it gives me 500 internal server error. How can it be done? Worst case please share an nginx solution for this.
Config I tried:
<VirtualHost *:80>
ServerName hello.world.com
ServerAlias hello.world.com
RewriteEngine On
RewriteRule ^ https://helloworld-zxtb3wfs2a-de.a.run.app [P]
</VirtualHost>
BTW the endpoint is a website and not just a simple JSON response. Though even JSON responses are not working for me either.
2
Answers
While rewriting the query back to the Cloud Run endpoint (*.run.app), you need to make sure you update
Host
header to match to that .run.app domain name as well. Otherwise, Cloud Run’s frontend IP won’t know where to send that.Check this question this question on how to do this with mod_rewrite, and make sure you use
ProxyPreserveHost Off
.Also since you’re getting HTTP 500, make sure you check the application logs to see if there’s something wrong with how the app handles this request.
I assume that you have already deployed your cloud run service with –ingress internal option, so that no one can access Cloud Run without the reverse proxy.
Follow the below steps to create a reverse proxy in front of the cloud run service. You can skip Steps 2 – 5 if you are not installing self-signed SSL and you have your own SSL configured