-1

This question is not for business use - this is for personal use. Here is my situation. I run a Windows Server 2012 R2 with a domain. I am now adding Home Assistant running on a Raspberry Pi (and running Raspbian).

I am retired so we travel some. So I want to be able to log into the Home Assistant when we are away from home to monitor things. I have registered my own domain on Amazon Route 53, and have it set up so that it tracks my external IP address, just like DDNS programs such as DuckDNS would do. I initially set up port forwarding on my router to forward port 443 to the Pi and it all worked, so I know it is all set up correctly up to that point.

Unfortunately, I also have some other programs that require https access so I can't just leave it set up to do the port forwarding on my router.

All that said I am now trying to set up Nginx on the Windows Server. I have got that done, and I have it set up to run as a service. But I am struggling with 2 problems:

  1. I can't get it to start, now that it is a service. it keeps giving an error 1067, which I think means there is a problem with the nginx.conf file. But I am not sure if there is actually a problem with the file, or if it does not find it because I don't have a path set up correctly for the service to know where the file is located. So how do I get that done correctly?

  2. And then the second question is what would the nginx.conf file look like to get the Windows server to listen on port 443 and if it sees a call for my Home Assistant domain, it forwards to the Raspberry Pi, otherwise it just lets the 443 traffic go on to the PC that is trying to pass traffic on port 443?

I hope this all makes sense, and that I have explained it all correctly. I am into new territory for me and I am a little lost on what to do next.

Dave M
  • 4,514
  • 22
  • 31
  • 30
Mike
  • 1
  • 1
  • My experience with `Error 1067` is from Windows 10, so I am not sure whether it carries over to Windows Server? - I saw 'Error 1067' and 'The process terminated unexpectedly' on Windows 10 a few days ago. The root cause was a dll file (`C:\Windows\System32AudioEndpointBuilder.dll`) with the wrong build version. My current build of Windows 10 is 10.0.17134 (= v1803). The wrong dll had version 10.0.14393. Once I replaced that dll with one having the right version, the service worked fine again. In your case, I would take a closer look at the versions of whatever dll(s) your service depends on. – Henke Sep 16 '20 at 11:26

1 Answers1

0

I’m not overly familiar with running NGINX on a Windows server, but here are some helpful pointers.

  1. NGINX is very particular about it’s configuration files, it blatantly refuses to start if there’s a single typo in the configuration file. So your error can be either that it can’t find the configuration file, or that there’s something wrong with the file.

  2. NGINX (at least on Linux) uses nested configuration files, so that you don’t end up with a humongous nginx.conf file to wade through.

So, you’ll need to set up a nginx.conf file in the same directory as your nginx.exeapplication

It should contain something along these lines

worker_processes  1;
events {
worker_connections  1024;
}

http {
include       mime.types;
default_type  application/octet-stream;
#to read external configuration.
include "C:/nginx/conf/sites-enabled/*.conf";
}

Note the last line with the include statement. That tells NGINX to include all configuration files in that sub directory in it’s main configuration file.

So, in that sub directory, create a new configuration file, for example mydomain.conf It should contain the something like this:

server {
    listen       80;
    server_name  mydomain.com;
    location / {
        root   html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

I would recommend you get this working first, before trying to configure it to listen to HTTPS on port 443, as you need to configure all the settings for certificates to get that working.

  1. What you’re trying to set up is called a reverse proxy, aka. if something calls a particular domain, for example homeassistant.mydomain.com, NGINX will pass the traffic on to another server. This is very common in the commercial sector, and it’s one of the applications that NGINX is particularly good at.
Stuggi
  • 3,506
  • 4
  • 19
  • 36