Score:0

nginx proxypass not working for embedded links

us flag

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!

rvs avatar
vn flag
rvs
You need to adjust/configure/fix software which is generating those links in html. What is it?
Axel avatar
us flag
@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?
rvs avatar
vn flag
rvs
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 avatar
vn flag
rvs
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?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.