# \[OH3\] Reverse proxy to subdirectory

**URL:** <https://community.openhab.org/t/oh3-reverse-proxy-to-subdirectory/114610>\
**Category:** Installation\
**Created:** [January 18, 2021, 11:16am UTC](https://community.openhab.org/t/oh3-reverse-proxy-to-subdirectory/114610 "2021-01-18T11:16:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreapier](https://community.openhab.org/user_avatar/community.openhab.org/andreapier/32/97002_2.png) [@andreapier](https://community.openhab.org/u/andreapier)\
**Post date:** [January 18, 2021, 11:16am UTC](https://community.openhab.org/t/oh3-reverse-proxy-to-subdirectory/114610/1 "2021-01-18T11:16:40Z")

</div>

- Platform information:
  - Hardware: aarch64/4GB/64GB
  - OS: Manjaro
  - Java Runtime Environment: java 11
  - openHAB version: 3.0

- Issue of the topic: Run openhab in a subdirectory in nginx reverse proxy
- Please post configurations (if applicable):
  - Items configuration related to the issue: none
  - Sitemap configuration related to the issue: none
  - Rules code related to the issue: none
  - Services configuration related to the issue: none

- If logs where generated please post these here using code fences: none

Hi,  
Did someone manage to run openhab 3.0 in a subfolder in nginx reverse proxy mode?  
I’d like to run in [http://myserver/smarthome](http://myserver/smarthome), ideally it should be as easy as configuring nginx as:

```
 location /smarthome {
         return 301 $scheme://$host/smarthome/;
 }

location /smarthome/ {
        proxy_pass http://localhost:8080/;
        proxy_buffering off;
        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;
}

```

However this is not working. If I navigate to [http://myserver/smarthome](http://myserver/smarthome) i can only see a blank page. Network pane shows the following:

 ![immagine](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/1/1/11f8ddbff0bc39f1eb1ad3ce68c1c6bb932a04c4.png)

I remember having a slightly different configuration for BasicUI in OH2, which works a little better, but still unusable:

```
location /smarthome {
        return 301 $scheme://$host/smarthome/;
}

location /smarthome/ {
        proxy_pass http://localhost:8080/;
        proxy_buffering off;
        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_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";

        sub_filter_types application/javascript text/xml text/css text/javascript application/json text/plain;
        sub_filter_once off;

        sub_filter '/rest/' '/smarthome/rest/';
        sub_filter '"/icon/' '"/smarthome/icon/';
        sub_filter '"/basicui/' '"/smarthome/basicui/';
}

```

The result is this, all requests complete with HTTP status 200, but it doesn’t work yet:

 ![immagine](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/5/a55af71e4ca4785b27a19c2a9b0a8f5226f4e3d2.png)

Any idea on how to fix this?

---

<div class="post-metadata">

**Author:** ![Wolfgang\_S](https://community.openhab.org/user_avatar/community.openhab.org/wolfgang_s/32/52719_2.png) [@Wolfgang\_S](https://community.openhab.org/u/Wolfgang_S)\
**Post date:** [January 18, 2021, 6:37pm UTC](https://community.openhab.org/t/oh3-reverse-proxy-to-subdirectory/114610/2 "2021-01-18T18:37:08Z")

</div>

Compared to your OH2 configuration this one ( [Nginx as reverse proxy for OH2 at non-root location - #8 by evertramos](https://community.openhab.org/t/nginx-as-reverse-proxy-for-oh2-at-non-root-location/22539/8) ) has a slightly different "proxy\_set\_header Host " entry. In post 12 in that thread configuration for paperui is mentioned.  
I did not test but hopes it helps in your case.

---

<div class="post-metadata">

**Author:** ![andreapier](https://community.openhab.org/user_avatar/community.openhab.org/andreapier/32/97002_2.png) [@andreapier](https://community.openhab.org/u/andreapier)\
**Post date:** [January 20, 2021, 4:29pm UTC](https://community.openhab.org/t/oh3-reverse-proxy-to-subdirectory/114610/3 "2021-01-20T16:29:43Z")

</div>

I don’t see any configuration where paper ui was confirmed working…  
Also, that thread has only 11 posts… what do you mean by post 12?  
The difference in host header is a test I made. Using `$host/smarhome` is even worse than `$host`

---

<div class="post-metadata">

**Author:** ![andreapier](https://community.openhab.org/user_avatar/community.openhab.org/andreapier/32/97002_2.png) [@andreapier](https://community.openhab.org/u/andreapier)\
**Post date:** [January 23, 2021, 11:01am UTC](https://community.openhab.org/t/oh3-reverse-proxy-to-subdirectory/114610/4 "2021-01-23T11:01:54Z")

</div>

After messing around and wasting many hours I ended up thinking this is not possible in OH3.  
I will use a subdomain even if this is not what I wanted to do.

---

<div class="post-metadata">

**Author:** ![billfor](https://community.openhab.org/letter_avatar_proxy/v4/letter/b/ce73a5/32.png) [@billfor](https://community.openhab.org/u/billfor)\
**Post date:** [February 1, 2021, 4:21am UTC](https://community.openhab.org/t/oh3-reverse-proxy-to-subdirectory/114610/5 "2021-02-01T04:21:19Z")

</div>

Read this post, for basicUI and the REST API in OH3.  
It works fine for me. I don’t need the mainUI at this point though, so you might have to do some additional tweaking.

> [@Openhab on Tesla Browser](https://community.openhab.org/t/openhab-on-tesla-browser/108346/2):
>
> OK I guess not slight_smile Here’s my working nginx configuration making openhab available at [https://yourdomain/openhab-tesla](https://yourdomain/openhab-tesla) via VouchProxy, while retaining BasicAuth at [https://yourdomain/openhab](https://yourdomain/openhab). This way I can use it in my car, and still keep the ios/android apps working. If anyone improves upon it or has an easier way, it would be great to know, especially if something in openhab3 obviates this. [vouch-openhab.txt](https://community.openhab.org/uploads/short-url/pADUWwlKFwpvTVMgWOWcp4hEaCa.txt) (6.8 KB)
