0

I'm using NGINX as a reverse proxy to send requests to localhost:3001. localhost:3001 contains a docker container running a fork of the local version of prerender.io. Thus, a full request would look like server/prerender/https://google.com, and a static, rendered version of google.com gets returned.

The issue is that when I proxy_pass the request to localhost:3001, the pre-renderer logs that it failed to pre-render 'https:/google.com' (a / in https:// was removed). I tested localhost:3001 directly without going through NGINX, and it pre-rendered fine. I tried re-approaching this via rewrite rules and removing the trailing / in proxy_pass, but the end product is the same where it logs that it can't pre-render 'https:/google.com'.

Setup:

 location /prerender/ { proxy_pass http://localhost:3001/; proxy_set_header Host $host; } 

Any idea on how to fix this issue?

3
  • I'm not 100% sure, but I was able to fix this issue by having the URL (google.com) be entered as a query so /prerender?url=, and I then extracted the arg_url and proxy_passed to localhost:3001/arg_url. I guess the issue was that NGINX was interpreting the URL as part of the actual path, so it interpreted the // in the same it way interprets the / in domain.com/prerender. Commented Nov 25, 2024 at 2:41
  • You can change this behavior with the merge_slashes directive. Commented Nov 25, 2024 at 3:02
  • @IvanShatsky Thank you! I had a feeling it was an intended behavior. Commented Nov 26, 2024 at 3:15

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.