FAILED: service nginx restart

Trying to upgrade from 14.04 to 18.04. After getting everything setup finally, and restoring my backup, I tried rerunning
# mailinabox

which ended with:

RTNETLINK answers: Network is unreachable

Primary Hostname: box.eladhen.com
Public IP Address: 165.227.150.231
Mail-in-a-Box Version:  v0.41

Updating system packages...
Installing system packages...
Initializing system random number generator...
Firewall is active and enabled on system startup
Installing nsd (DNS server)...
Installing Postfix (SMTP server)...
Installing Dovecot (IMAP server)...
Installing OpenDKIM/OpenDMARC...
Installing SpamAssassin...
Installing Nginx (web server)...

FAILED: service nginx restart
-----------------------------------------
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
-----------------------------------------

Running:

systemctl status nginx.service

Got me:

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 Sat 2019-03-30 23:40:06 IDT; 4min 7s ago
     Docs: man:nginx(8)
  Process: 7005 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Mar 30 23:40:04 box.mybox.com systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 30 23:40:06 box.mybox.com nginx[7005]: nginx: [emerg] BIO_new_file("/home/user-data/ssl/box.mybox.com-20190628-a44560
Mar 30 23:40:06 box.mybox.com nginx[7005]: nginx: configuration file /etc/nginx/nginx.conf test failed
Mar 30 23:40:06 box.mybox.com systemd[1]: nginx.service: Control process exited, code=exited status=1
Mar 30 23:40:06 box.mybox.com systemd[1]: nginx.service: Failed with result 'exit-code'.
Mar 30 23:40:06 box.mybox.com systemd[1]: Failed to start A high performance web server and a reverse proxy server.

Can anyone help?

Was this a fresh 18.04 install?

Your error message is pointing to a problem in the nginx.conf file. Can you share that maybe?

You can test the nginx config with:

nginx -t

And it should tell you the lines that have errors.

The output of nginx -t is already shown in the OP … hence my deleted post.

Mar 30 23:40:06 box.mybox.com nginx[7005]: nginx: [emerg] BIO_new_file("/home/user-data/ssl/box.mybox.com-20190628-a44560
Mar 30 23:40:06 box.mybox.com nginx[7005]: nginx: configuration file /etc/nginx/nginx.conf test failed

It seems that OP solved this as I can access his MiaB’s Roundcube.

It was a fresh install on digital ocean after doing Droplet > Destroy > Rebuild.

Anyway, sadly I HAD to have email on Sunday (it’s a workday here) and had to sleep, so I restored my 14.04 snapshot… I’ll try again another day…

So can’t check nginx.conf at the moment…

It was after restoring the backup from the older box…

Gotcha! When you try again and if you have the same problem come to the Slack room … something like the problem you had is hard for me to diagnose, but easy to solve - if that makes sense …

How do I get to the slack room?

There is a link to join located on the main Mail-in-a-Box webpage.

I’m also getting this same issue. Would be really nice to see if you come up with a solution!

The issue @eladhen is having seems to be SSL related …

@Kw0mE are you getting the exact same error?

Yes, I get the same error. I did a fresh install on 18.04 when I restore my backups I get this error and then I cant connect to the web control pannel or anything.

If you have time now, and are willing to go to the Slack channel we can trouble shoot. Slack is a bit easier than PM – if you don’t want to use Slack we can PM.

Ok so I think I found a solution! I’m still quite fresh to Linux so this will probably make you cringe haha.

Fresh install of 18.04

Sudo apt update
Sudo apt upgrade
Curl -S https://mailinabox.email/setup.sh | sudo bash

Copy backups and key to
home/user-data/restore

Export passphrase=$(cat /home/user-data/restore/secret_key.txt)

Sudo -e duplicity restore —force file:///home/user-data/restore/encrypted /home/user-data/

Then copy the entire folder of home/user-data/ssl from the old box to the new one

Sudo mailinabox

And it worked…

Edit:
After doing all of this I scrolled back through the terminal and found this error

Error ‘[Errno 17] File exists’ processing ssl/ssl_certificate.pem

So maybe removing this file is the key step? I have a feeling I may have read this somewhere before on the forum when I first tried to upgrade early March and it went straight over my head.

1 Like

Yes, the solution I would have proposed would have been to remove the contents of the /home/user-data/ssl directory and then run

sudo /home/user/mailinabox/setup/ssl.sh

replace “/home/user” with the location of your mailinabox install directory. (Either /home/user or /root - dependent upon which user you used.)

and finally

sudo mailinabox

This will be the solution for anyone who does not still have their Ubuntu 14.04 box running (only have the encrypted backups) – in the case of a VPS provider who required the original VPS to be destroyed to retain the IP address.

Tried this.

after Running sudo mailinabox in the end I got:
ln: failed to create symbolic link '/home/user-data/ssl/ssl_certificate.pem': File exists

the web interface says: that I’m self signed.

Trying to provision let’s encrypt gets me this:

Log:

Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator webroot, Installer None You should register before running non-interactively, or provide --agree-tos and --email <email_address> flags.

Did you follow Kw0mE’s or my suggestions? I am thinking that there may be a flaw in mine.

worked for me thanks!!

I ran into this same problem while moving my trusted home install to a vps (details on the why later) :slight_smile:

For some reason the symbolic link

ssl_certificate.pem → /home/user-data/ssl/box.mydomain.eu-selfsigned-20220217.pem

that is created when installing a fresh box was not overwritten by the current one from the backup; duplicity gives an error to that effect.

If you subsequently run ‘sudo mailinabox’ it bails out with an error when trying to start nginx.

What I did to solve this (building on the info in this thread) is delete the symbolic link and create a new one pointing to the latest available .pem file for your box. This file is found in /home/user-data/ssl, in my case

/home/user-data/ssl/box.mydomain.eu-20220402-2fd5e33f.pem

so the command becomes

ln --symbolic /home/user-data/ssl/box.mydomain.eu-20220402-2fd5e33f.pem ssl_certificate.pem

If your old instance is still running you can find the target for the symbolic link there.

After this ‘sudo mailiniabox’ runs without problems and you end up with a working MIAB.