2

I have an application hosted in Google App Engine. I want to use Nginx as a reverse proxy.

The proxy_pass already works, but it rewrites the URL (e.g. hitting 34.34.34.34 in the address bar redirects to sample-domain-dot-project.appspot.com AND rewrites the URL), which is something I want to avoid.

Previous solutions, already working in production (AWS servers), consisted of applying the Host header.

proxy_set_header Host $host;

However, in Google App Engine, this setting alone makes the redirect not working anymore, returning Google's 404 error page.

sites-enabled/sample.com.br

server {
    listen 80;
    client_max_body_size 1000M;

    location / {
        proxy_pass_request_headers on;
        proxy_set_header Host $host;
        proxy_pass https://sample-domain-dot-project.appspot.com;
    }
}
2
  • 1
    I followed the quicktutorial for the custom runtime in GAE flex and your configuration. I didn't get a 404 error. Could you provide more information about your use case? Are you using GAE standard or flexible? What runtime? Could you provide the whole configuration of your application(app.yaml, Dockerfile, etc)?
    – tzovourn
    Dec 23, 2019 at 15:38
  • Sory for the delay. I actually managed yesterday to make it work. The problem was that I was using the IP as the server_name, which was strange, because when our software was in AWS, we didn't have this issue. Dec 28, 2019 at 20:41

1 Answer 1

3

I solved it by creating a DNS and providing it using the server_name directive in the conf. For some reason, GCloud does not allow using the IP in the Host header, something I never had any problem using AWS services.

6
  • 2
    i think the reason for this is that google decided to choose the services via hostname?
    – djdomi
    Dec 28, 2019 at 21:57
  • I don't know the bottom of it, unfortunately. It's a good hypothesis, though. Dec 28, 2019 at 22:06
  • for me is it clear in case they use a shared ip (i. e. my server has even only 1 main ip for round about 25 domains)
    – djdomi
    Dec 28, 2019 at 22:41
  • @Patrick Villela, I'm not really sure I understand what your final config looks like (and regarding the DNS, did you create one on google cloud ?), coud your provide more details ? Aug 4, 2020 at 10:13
  • @CyrilDuchon-Doris sorry about that. Unfortunately, it's been a while, but from what I remember, I used to only have the IP address on the server_name directive when I was using AWS, because only internally would we use this machine. GCloud, it seems, do not allow it, requiring every configuration to use the domain name. So what I did was, instead of "server_name x.x.x.x", I had to use "server_name domain.com". I'm not sure (I was not the one creating it), but the DNS was probably created in GCloud as well, for our old one was in AWS. Aug 5, 2020 at 13:41

You must log in to answer this question.

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