Installation Nginx from Habian-config doesn't work

Dear all,
I try to install nginx revere proxy from the habian-config menu (running on Debian 10 on a laptop).
During the last step I get an error message and the config-menu tells me to report here in the community forum.
When I close the config-menu, I see these last lines with the error:

nginx: [emerg] “server_name” directive is not allowed here in /etc/nginx/sites-enabled/openhab:8
nginx: configuration file /etc/nginx/nginx.conf test failed
2020-05-02_21:31:27_CEST [openHABian] Checking for default openHABian username:password combination… SKIPPED (method not implemented)

all files in /etc/nginx and /etc/nginx/sites-enabled have owner:group root:root and -rw-r–r--.
Any advice?

Post /etc/nginx/nginx.conf and /etc/nginx/sites-enabled/openhab.

(and there is no such thing as habian-config it’s openhabian-config)

Thanx for helping me Markus.

I know, I always have to look that up. I wrote it to tell you what I am talking about, not as a manual. But you are right, should have written it correct for other users searching for info themselves.

In the attachements you find my openhab and nginx.conf -files:
openhab.txt (2.0 KB) nginx.conf.txt (2.0 KB)

The file: /var/log/nginx/error.log is empty, and /etc/nginx/.htpasswd exists and has one line for the user I expected.

What do you mean by “does not work” ? Do you get an error during install ?
Since you show the files I assume installation worked.
What did you enter ?

And most important: what is it that does not work? Where’s the problem ?
What’s the output of ‘nginx -t’ ?

It’s really cumbersome if I/we have to ask for every detail so be more verbose and precise, please.

The only message that I get in openhabian-config is: ‘The installation of NGINX did not succeed, get help from the community’.
Then when I close openhabian-config, I see these messages that I posted in my first message.

nginx: [emerg] “server_name” directive is not allowed here in /etc/nginx/sites-enabled/openhab:8
nginx: configuration file /etc/nginx/nginx.conf test failed

[openHABian] Checking for default openHABian username:password combination… SKIPPED (method not implemented)

I did not get any other message!
When I try to connect the app, I thought it did not do anything, but that turned out to be a problem with port forwarding. But what does go wrong, is that I do not gave to use any username or password. Anything goes, even leaving u.n. and p.w. blank!

When I portforward port 80 to openhab, I get a page: ‘Welcome to nginx!~’ So nginx is running, but it’s not asking for credentials.

I’m sorry I didn’t tell that right away, but that was because I simply didn’t know. When the openhabian-config told me the installation didn’t succeed, I thought that it really didn’t. Now I see it did do something but not all is working. I really thought I told you all there is. I would never ask for help and deliberately leave out stuff that is important for the solution.

Answer my questions please.

nginx: [emerg] “server_name” directive is not allowed here in /etc/nginx/sites-enabled/openhab:8
nginx: configuration file /etc/nginx/nginx.conf test failed

Line 8 in that file contains no such directive. I believe you have messed up your nginx setup earlier.
Upgrade to latest openhabian, delete nginx (apt-get purge nginx; rm -rf /etc/nginx), and reinstall using option 43.

Sorry, I missed the nginx -t part from your post. It gives me:
nginx: [emerg] “server_name” directive is not allowed here in /etc/nginx/sites-enabled/openhab:8
nginx: configuration file /etc/nginx/nginx.conf test failed

After flush nginx and remove the directories, I reinstalled using option 43. After the ssl-stuff I get the same error message, which I copied in the attached png-file.error

After closing openhabian-config I see these lines at the end of nginx-installation:

Selecting previously unselected package nginx.
(Reading database … 156736 files and directories currently installed.)
Preparing to unpack …/nginx_1.14.2-2+deb10u1_all.deb …
Unpacking nginx (1.14.2-2+deb10u1) …
Setting up nginx (1.14.2-2+deb10u1) …
Updating FireMotD available updates count …
cp: cannot create regular file ‘/etc/nginx/sites-enabled/openhab’: No such file or directory
sed: can’t read /etc/nginx/sites-enabled/openhab: No such file or directory

And at the end of filling in the ssl-stuff:

sed: can’t read /etc/nginx/sites-enabled/openhab: No such file or directory
sed: can’t read /etc/nginx/sites-enabled/openhab: No such file or directory
sed: can’t read /etc/nginx/sites-enabled/openhab: No such file or directory
sed: can’t read /etc/nginx/sites-enabled/openhab: No such file or directory
sed: can’t read /etc/nginx/sites-enabled/openhab: No such file or directory
sed: can’t read /etc/nginx/sites-enabled/openhab: No such file or directory
nginx: [emerg] open() “/etc/nginx/nginx.conf” failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
2020-05-05_11:28:06_CEST [openHABian] Checking for default openHABian username:password combination… SKIPPED (method not implemented)

When I cd to /etc/nginx, this directory does not exist. But When I connect my browser to my outside ip, I get the ngix welcome-page: welcome

And again, I can use the openhab-app without using authentication…

I was able to reproduce your issue.

Restore /etc/nginx and below from backup.
Edit /etc/nginx/sites-enabled/openhab. Uncomment the lines of the first section to see if nginx -t succeeds.

It is a relief that you can reproduce this!
Sorry I’d I sound stupid, but how do I restore from backup?
I tried ‘sudo restore> ls’ but that command is not known on my Debian install.

Depends on what you have setup to backup your system.If you followed the recommendation and installed Amanda, here’s the README.

Ah, that’s what you mean. Ok, but it’s a completely new install. So I don’t have a backup of the nginx directories.

You can try apt-get purge nginx nginx-common; apt-get install nginx
Else reinstall. No backup no pity !

I understand youth don’t have pity with someone who doesn’t make backups.
What I don’t understand is why you expect me to make a backup of a fresh install when it is finished only half.
I do have the old installation, but that was on Debian 9 with openhab 2.4. Can I use that nginx backup? Or do I only need the file etc/nginx/sites-enabled/openhab?

Since it’s a fresh install, and since installing and reinstalling didn’t help, I’m afraid this is going nowhere.
I will try the backup from the old installation, if that fails I give up on nginx and keep an eye on this forum for others with the same problem on new installs.

Thanx for your help anyway.

The commands in my previous post should restore nginx config so where’s your problem.

My problem seams to be that I am not able to explain to you that installing nginx does not result in the proper directories with a working result. Must be my English. Nevermind, thanks for trying.

No, your problem is that you don’t do what I advised you to:

That’ll (re-)install the nginx-common package which will re-generate your missing dir.

If i use the openhabian config with openhab version 3 and change the

location /
to
location /openhab

So i can use ip/openhab I only get BLACK page loading.
What could be wrong?

location in oh is unrelated to the OS (openhabian) or nginx so please move your post to an own thread of yours.

I’m talking in openhab config for NGINX

location / { … will work all but frontail
location /openhab {… i get black openhab3 screen