I am writing an Nginx configurations for Crystal-Lang based application to send all the traffic http://example.com/videos/
to http://0.0.0.0:3000
via reverse proxy.
I have written the following config which is not working and I'm heading over the internet but no luck.
When I go to http://example.com/videos/
, application internally performing a redirect from http://example.com/
to http://example.com/feed/popular
which is the problem, it redirects to http://example.com/feed/popular
which is wrong, I need /videos/
part to always concatenated with URL like http://example.com/videos/xxxx
always but after redirect the /videos/
part is being chopped out.
So the application should consider http://example.com/videos/
as host.
Here is my config:
server {
listen 80;
server_name elearn.com.pk default_server localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location /videos/ {
proxy_pass http://0.0.0.0:3000/;
proxy_http_version 1.1;
rewrite /videos/(.*) /$1 break;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host/videos/;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Can someone please help me to resolve this issue please? Thanks.