Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

nginx docker redirect no trailing slash to trailing slash

server {
    listen 80;
    listen 443 ssl http2;
    
    ...

    # This is the line that redirects uris with missing / (it adds it to the uri)
    rewrite ^/repairapp/([^static].*[^/])$ /repairapp/$1/ permanent;
    
    # This is nginx serving my static files
    location /repairapp/static/ {
        alias /var/www/repairapp/static/;
    }
    
    # This is the uri that maps to my app (no file serving here)
    location /repairapp/ {
        proxy_pass http://repairappcontainer:8000/;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
    
    ...
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nginx #docker #redirect #trailing #slash #trailing #slash
ADD COMMENT
Topic
Name
2+9 =