Might be too late on that… but for the record … we got this working in subdirectory with the same code as of @kohlsalem, only added the host header, as of:
location /openhab/ {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host/openhab;
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;
# change the normal "start" redirect directly to the basic ui;
proxy_redirect http://openhab/start/index /openhab/basicui/app;
sub_filter_types application/javascript text/xml text/css text/javascript application/json text/plain;
sub_filter_once off;
sub_filter '/rest/' '/openhab/rest/';
sub_filter '"/icon/' '"/openhab/icon/';
sub_filter '"/basicui/' '"/openhab/basicui/';
## Password Protection
auth_basic "Username and Password Required";
auth_basic_user_file /etc/nginx/.htpasswd;
}
Detail for this line:
proxy_set_header Host $host/openhab;
Hope it helps others!