#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { try_files $uri @__NAME__; } location __PATH__/protected/ { internal; alias /opt/__NAME__/__NAME__/smedia/; } location __PATH__/media { alias /opt/__NAME__/media; } location __PATH__/static { alias /opt/__NAME__/static; } location __PATH__/assets { alias /opt/__NAME__/static; } location @__NAME__ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://unix:/opt/__NAME__/sock; }