New install - behind reverse proxy - Basic UI throws "Offline: waiting for connection to become available"

I spent a lot of time chasing this error within OH2 but I think the real problem is with my reverse proxy config.

I happen to be using Nginx reverse proxy and only the very basic/minimum rp settings. I think I need to fix that…

My Nginx Config

cat /etc/nginx/sites-enabled/oh2..com.conf
server {
server_name oh2..com;

listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/maritimeopscorp.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/maritimeopscorp.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

root /var/www/html;

index index.html index.htm index.nginx-debian.html;

location / {
proxy_pass http://localhost:8080;
}
}
server {
listen 80;
listen [::]:80;
server_name oh2..com;

if ($host = oh2.<my domain>.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot

return 404; # managed by Certbot

}

Throws this error on the Basic UI with my site map set…

[error] 1061#1061: *200 upstream timed out (110: Connection timed out) while reading upstream, client: 72.94.193.45, server: oh2..com, request: “GET /rest/events HTTP/1.1”, upstream: “http://127.0.0.1:8080/rest/events”, host: “oh2..com”, referrer: “https://oh2..com/paperui/index.html”

I think these flags helped solve it (we’ll see if it holds up over time)

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;

I recall we had to add some flags for that but not which ones.
You could have a look at openHABian’s nginx config.
Or why not use it ?

Excellent resource to learn more about the problem. I just did a quick copy/paste to put the suggestion into the server and location blocks but am still getting an error. I have NOT spent much time yet on this recommendation yet just because of my weekend family time but I certainly will.

Thank you for the lead @mstormi

2020/05/24 15:42:42 [error] 1040#1040: *2280 upstream timed out (110: Connection timed out) while reading upstream, client: 72.94.193.45, server: oh2.my_domain.com, request: “GET /rest/events HTTP/1.1”, upstream: “http://127.0.0.1:8080/rest/events”, host: “oh2.my_domain.com”, referrer: “https://oh2.my_domain.com/paperui/index.html”

2020/05/24 15:43:03 [error] 1040#1040: *2431 upstream timed out (110: Connection timed out) while reading upstream, client: 72.94.193.45, server: oh2.my_domain.com, request: “GET /rest/sitemaps/events/fae0a087-2035-49f1-ab66-c6acbb34f2be?sitemap=marina&pageid=marina HTTP/1.1”, upstream: “http://127.0.0.1:8080/rest/sitemaps/events/fae0a087-2035-49f1-ab66-c6acbb34f2be?sitemap=marina&pageid=marina”, host: “oh2.my_domain.com”, referrer: “https://oh2.my_domain.com/basicui/app”

Hmmm… looking at the error message it seems like the client rest call is timing out so I manually tried the rest call from my browser and it DID time out.

https://oh2.my_domain.com/rest/sitemaps/events/c5e38686-d5f8-45e9-98a6-6e4520459f64?sitemap=marina&pageid=marina

2020/05/24 16:08:43 [error] 1865#1865: *4293 upstream timed out (110: Connection timed out) while reading upstream, client: 72.94.193.45, server: oh2.my_domain.com, request: “GET /rest/events HTTP/1.1”, upstream: “http://127.0.0.1:8080/rest/events”, host: “oh2.my_domain.com”, referrer: “https://oh2.my_domain.com/paperui/index.html”

The exact file from OpenHabian results in the same error. It must be something else.

The rest call from the internet is timing out.

I used the non-https flavor of the open habian sample and this times out
http://oh2.my_domain.com/rest/sitemaps/events/c5e38686-d5f8-45e9-98a6-6e4520459f64?sitemap=marina&pageid=marina

Adding

proxy_read_timeout 3600;

in the location / {} block seems to have fixed it for me. That extends the timeout to 1 hour.

2 Likes

Thanks that seems to have worked for my own install. I’ve added that to openHABian (issue #1000 :tada:)

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.