📜  nginx docker将无斜杠重定向到斜杠 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:46.396000             🧑  作者: Mango

代码示例1
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;
    }
    
    ...