0

I've an EC2 machine which is behind a ALB. Listener rules in the ALB are like

IF
Path is/blog*
Host is abc.example.com

THEN
Forward to
target-group-1

My nginx config looks like this:

##

# Default server configuration

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location /blog {
        proxy_pass https://abc.webflow.io/;
    }
}

Main page opens fine at abc.example.com/blog

but embedded links are not opening and giving 502 bad gateway when opened through DNS defined in ALB listener rules and when directly opened using EC2 instance IP are giving 404 not found

When I click on embedded links inside the main page, URL in the browser shows abc.example.com/categories/something/

and gives the above HTTP codes but if I manually edit the url in the browser and type it as: abc.example.com/blog/categories/something/ then page opens fine.

I'm trying to find how to rewrite the URL in such a way that it contains the sub-folder name as well but can't find anything.

Any help will be great!

Axel
  • 421
  • 2
  • 8
  • 18
  • You need to adjust/configure/fix software which is generating those links in html. What is it? – rvs Dec 13 '21 at 14:23
  • @rvs Those are 3rd party assets and I'm trying to proxypass to basically their website which we use for easier web development. Anyway we can adjust it on our side? – Axel Dec 13 '21 at 14:25
  • You can try to rewrite html in fly but it's error-prone and I'd recommend against doing that. If changing html is not possible, take a step back and see if you can archive your goal in some other way. – rvs Dec 13 '21 at 14:28
  • Also take a look here: https://stackoverflow.com/questions/32542282/how-do-i-rewrite-urls-in-a-proxy-response-in-nginx - maybe some of the suggestions will work for you? – rvs Dec 13 '21 at 14:29

0 Answers0