0

I'm deploying an angular app on a ubuntu nginx server. It's working fine with the default location /. In my case I'm trying to specify the location as location /ss and wanted to redirect to the intended page. But it in console it's trying to fetch sources from a different location(file path). Here what's working fine.

http://example.com:81/#/screenshots

with

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://localhost:8000;
    proxy_set_header Host $http_host;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off;
}

But I wanted

http://example.com/ss

this to redirect to the http://example.com:81/#/screenshots this url. I tried

location /ss {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://localhost:8000/#/screenshots;
    proxy_set_header Host localhost:8000/#/screenshots;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off;
}

But my console log says

GET http://example.com:81/app.js net::ERR_ABORTED
ss:44 GET http://example.com:81/view1/view1.js net::ERR_ABORTED
ss:45 GET http://example.com:81/screenshots/screenshots.js 
net::ERR_ABORTED

these kind of file locating problems. Is there a way to fix this in nginx conf level?

1 Answer 1

1
location ~ ^/ss {
    return 301 http://example.com:81/#/screenshots;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.