Hyper-V VM & Nginx proxy_pass seems to be timing out until ping

19 Views Asked by At

I've got a DigitalOcean droplet acting as a proxy between my home server [where I host my websites] and the internet; the droplet is running Ubuntu 22.04.4 LTS and nginx/1.18.0.

My home server is running Windows Server 2022 and just one test virtual machine via Hyper-V; the VM is running Ubuntu 22.04.4 LTS and nginx/1.18.0.

UFW is disabled at both ends right now.

The website pulls up correctly once in a while, but it appears something after the DigitalOcean droplet is refusing the connection pretty often; it's almost as though Windows, Hyper-V or Nginx is going to sleep.

Here's the most recent error on the DigitalOcean side (the connection never reaches the VM so there's no logs for this there):

2024/03/25 10:38:31 [error] 1322#1322: *827 upstream timed out (110: Unknown error) while connecting to upstream, client: 73.xx.xx.xx, server: www.my-website.com, request: "GET / HTTP/2.0", upstream: "http://73.xx.xx.xx:715/", host: "www.my-website.com"

I've got the Windows machine running in performance mode and all the settings are configured to not allow the computer or drives to go to sleep.

I've got my router forwarding all necessary ports (80, 443 and 715) to the VM's LAN IP.

When I bring the website up in the browser and it doesn't immediately load, I ssh into the VM and ping my-website.com and all the sudden the website loads in the browser - so it's almost like it needs a ping to "wake up."

Here's my DigitalOcean nginx config file for my-website.com (my-website.com.conf):

server {
  listen 80;
  server_name my-website.com www.my-website.com;
  return 301 https://www.my-website.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name my-website.com;

    ssl_certificate /etc/letsencrypt/live/my-website.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my-website.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    return 301 https://www.my-website.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name www.my-website.com;

    ssl_certificate /etc/letsencrypt/live/my-website.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my-website.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header HTTPS "on";
        proxy_http_version 1.1;
        proxy_set_header   "Connection" "";
        proxy_pass http://73.xx.xx.xx:715;
  }

}

Here's my home server nginx config file for my-website.com (my-website.com.conf):

server {
    listen 715;
    listen [::]:715;

    server_name my-website.com www.my-website.com;

    access_log /home/yo/websites/logs/my-website-access.log custom;
    error_log /home/yo/websites/logs/my-website-error.log warn;

    root /home/yo/websites/my-website.com;
    index index.html;

}

The only solution I can come up with is to set up a cron on the VM to ping the website every few minutes...which isn't ideal.

0

There are 0 best solutions below