NGINX config clarification

Ok. You created the ssl folder in /etc/nginx/ manually?

1 Like

I just created the folder and ran the command. We’ll see what happens. Thanks for your help.

Yes I did that.

~Cheers

Unable to start nginx. Not sure what I missed. It was running when i first installed it as I stopped it manually. Tried rebooting RPi, no luck.

pi@hassbian:~ $ sudo systemctl status nginx.service -l
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Wed 2017-03-15 13:10:51 EDT; 45s ago
  Process: 706 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Mar 15 13:10:50 hassbian systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 15 13:10:51 hassbian nginx[706]: nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1
Mar 15 13:10:51 hassbian nginx[706]: nginx: configuration file /etc/nginx/nginx.conf test failed
Mar 15 13:10:51 hassbian systemd[1]: nginx.service: control process exited, code=exited status=1
Mar 15 13:10:51 hassbian systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Mar 15 13:10:51 hassbian systemd[1]: Unit nginx.service entered failed state.

Not sure what to tell you here can’t really help you any more then the error message without having the config file…

~Cheers

This /etc/nginx/sites-available/hass file?

I can post that. Should that file have an extension?

You could try to remove this part:

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

and also the very last “}” as I don’t have that in my nginx config.

~Cheers

pi@hassbian:~ $ sudo systemctl status nginx.service -l
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
Active: failed (Result: exit-code) since Wed 2017-03-15 13:22:46 EDT; 11s ago
Process: 1920 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Mar 15 13:22:46 hassbian nginx[1920]: nginx: [emerg] unknown directive “myserver.duckdns.org” in /etc/nginx/sites-enabled/default:4
Mar 15 13:22:46 hassbian nginx[1920]: nginx: configuration file /etc/nginx/nginx.conf test failed
Mar 15 13:22:46 hassbian systemd[1]: nginx.service: control process exited, code=exited status=1
Mar 15 13:22:46 hassbian systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Mar 15 13:22:46 hassbian systemd[1]: Unit nginx.service entered failed state.

I just found a typo in my config. Will report back.

No luck. Still failing to start. My hass file is basically a copy and paste from the tutorial. Edited with my duckdns info. The items I edited below.

server {
        # Update this line to be your domain
        myhostname.duckdns.org;

        # These shouldn't need to be changed
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        return 301 https://$host$request_uri;
    }

    server {
        # Update this line to be your domain
        myhostname.duckdns.org;

ssl_certificate /etc/letsencrypt/live/myhostname.duckdns.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myhostname.duckdns.org/privkey.pem;

Think I figured it out.

should be

server {
        # Update this line to be your domain
        server_name myhostname.duckdns.org;

Same for the second server entry.

I quit. lol. Nothing seems to want to make this work. Very frustrating.

@Mike_D – I use this NGINX configuration. Works great, highly suggest!

Thanks @brianjking. I was just reading that thread. I uninstalled nginx and I’m going start again fresh.

Generate stronger Diffie Hellman Ephemeral parameter

cd /etc/ssl/certs
sudo openssl dhparam -out dhparam.pem 4096

I know this step says it will take a long time, but it’s been going for 3 hours! That can’t be right!?

Can I ctrl+c and run it again?

It’ll run for quite a while, I can’t recall how long it took on my Raspberry Pi 3. Yes, you could cancel, but honestly I’d just let it continue to run.

Run it on a desktop or laptop and copy it over. Mine took forever when I tried. I just gave up and did it on a better system

Thanks @forsquirel. I just ended up letting it run overnight. Not sure how long it took but it was done when i checked it this morning.

@Mike_D – Are you all set then?

@brianjking I am. All is working now. Appreciate your help. Thanks.

Also thanks to @PhyberApex and @forsquirel for your help as well.

1 Like