Unable to get https certificate for openhab2

Then restart nginx
and reshow:
netstat -pant | grep -i nginx

1 Like

I am unable to restart nginx service, I am getting below error,

ananth@ananth:~$ sudo systemctl restart nginx.service 
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
ananth@ananth:~$ sudo systemctl status nginx.service 
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-12-20 11:04:01 IST; 29s ago
  Process: 30927 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 30930 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 17413 (code=exited, status=0/SUCCESS)

Dec 20 11:04:01 ananth systemd[1]: Starting A high performance web server and a reverse proxy server...
Dec 20 11:04:01 ananth nginx[30930]: nginx: [emerg] unknown directive "lHost" in /etc/nginx/sites-enabled/https.conf:3
Dec 20 11:04:01 ananth nginx[30930]: nginx: configuration file /etc/nginx/nginx.conf test failed
Dec 20 11:04:01 ananth systemd[1]: nginx.service: Control process exited, code=exited status=1
Dec 20 11:04:01 ananth systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 20 11:04:01 ananth systemd[1]: nginx.service: Unit entered failed state.
Dec 20 11:04:01 ananth systemd[1]: nginx.service: Failed with result 'exit-code'.

1 Like

If you added the vhost config in the /etc/apache2/sites-enabled/000-default.conf file, just delete this file:

1 Like

I have deleted https.conf files in /etc/apache and /etc/nginx. I am getting below output,

ananth@ananth:~$ sudo systemctl restart nginx.service 
ananth@ananth:~$ sudo netstat -pant | grep -i nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      32485/nginx -g daem
tcp6       0      0 :::80                   :::*                    LISTEN      32485/nginx -g daem

1 Like

Please show:
nginx -t

1 Like

Please view it,

ananth@ananth:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

1 Like

From inside the 4443 block, remove:

and (near the bottom) one of the

1 Like

Although the nginx -t (test) passed…
It seems it may not like server {block} (inside a vhost) inside another server{block}.
Hopefully that will fix get the 4443 problem and get it running.
Restart nginx and show:
netstat -pant | grep -i nginx

1 Like

You want me to remove “server {” aand “}”, not code inside in that.

1 Like

Correct, only delete the start and end for server block - leave all the code inside.
I worked hard to create it just for you :wink:

1 Like

yes… You are working hard for me to solve this issue. I have other projects are running parallel but I am giving important to this. I will update you the result.

1 Like

I have modified code in "/etc/apache2/sites-enabled/000-default.conf ",

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =veplopenhab.ga
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>


<VirtualHost *:4443>
#server {
  listen 4443 ssl;
  server_name veplopenhab.ga;

  ssl_certificate /etc/letsencrypt/live/veplopenhab.ga-0001/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/veplopenhab.ga-0001/privkey.pem;

#  error_log    /location/to/error.log.file

  location / {
   proxy_pass https://localhost:8443/;
   proxy_set_header Host $http_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;
   satisfy any;
   allow 10.0.0.0/8; # ONLY Internal network has access
   allow 127.0.0.1;
   deny all;
  }
 #}
</VirtualHost>

Still, issue is not resolved.,

ananth@ananth:~$ sudo systemctl restart nginx.service 
ananth@ananth:~$ sudo netstat -pant | grep -i nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2368/nginx -g daemo
tcp6       0      0 :::80                   :::*                    LISTEN      2368/nginx -g daemo

1 Like

For testing, try changing:

to:
listen 4443;

1 Like

I have removed “ssl” from the code,

listen 4443;

still, getting the same issue.

1 Like

I am not understanding why it fails.
I will try that vhost config in lab and get back to you on what I find.

1 Like

We have been working with the wrong file :cry:
That is an APACHE file.
We need to modify an NGINX file.

EPIC FAIL

1 Like

Oh… That’s why when I modified a file, I have mentioned its whole path for visibility. I thought you have noticed. I need to modify some file in nginx folder like “/etc/nginx/sites-enabled/000-default.conf”.

Am I correct?

1 Like

YES! NGINX
Please show:
ls -l /etc/nginx/sites-enabled/

1 Like

I can revert the changes which I made in "/etc/ apache2 /sites-enabled/000-default.conf "

ananth@ananth:~$ sudo ls -l /etc/nginx/sites-enabled/
[sudo] password for ananth: 
total 0
lrwxrwxrwx 1 root root 34 Dec  7 11:45 default -> /etc/nginx/sites-available/default

1 Like

Please show file:

and also file:
/etc/nginx/nginx.conf
or output of:
grep -Eri 'include|listen|virtual|server_|ssl_cert' /etc/nginx/

1 Like