[SOLVED] Not asked for password when going via 8080

  • Platform information:
    • Hardware: Lenovo Laptop, AMD
    • OS: Ubuntu Server 18.04 (headless)
    • Java Runtime Environment: Zulu 8
    • openHAB version: openHAB 2.4.0 Release Build

I have set up security as per https://www.openhab.org/docs/installation/security.html. When I browse to my ip, I get challenged for the username and password but not if I go via port 8080.

Is it possible to force http://ip:8080 to also require the username and password that was created with htpasswd?

Change your openHAB configuration so that it only listens on localhost for 8080.

No, but you can do as recommended by the other poster so it does not respond on port 8080.

I tried adding

listen localhost:8080;

But as I already have

 listen 443 ssl;
 listen [::]:443 ssl;

It appears to be a problem.

/etc/nginx/sites-enabled$ 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 Wed 2019-10-23 22:08:45 NZDT; 1min 44s ago
Docs: man:nginx(8)
Process: 11602 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 11616 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 11603 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 10929 (code=exited, status=0/SUCCESS)

Oct 23 22:08:43 server2 nginx[11616]: nginx: [warn] conflicting server name “192.168.1.25” on [::]:443, ignored
Oct 23 22:08:43 server2 nginx[11616]: nginx: [emerg] bind() to 127.0.0.1:8080 failed (98: Address already in use)
Oct 23 22:08:43 server2 nginx[11616]: nginx: [emerg] bind() to 127.0.0.1:8080 failed (98: Address already in use)
Oct 23 22:08:44 server2 nginx[11616]: nginx: [emerg] bind() to 127.0.0.1:8080 failed (98: Address already in use)
Oct 23 22:08:44 server2 nginx[11616]: nginx: [emerg] bind() to 127.0.0.1:8080 failed (98: Address already in use)
Oct 23 22:08:45 server2 nginx[11616]: nginx: [emerg] bind() to 127.0.0.1:8080 failed (98: Address already in use)
Oct 23 22:08:45 server2 nginx[11616]: nginx: [emerg] still could not bind()
Oct 23 22:08:45 server2 systemd[1]: nginx.service: Control process exited, code=exited status=1
Oct 23 22:08:45 server2 systemd[1]: nginx.service: Failed with result ‘exit-code’.
Oct 23 22:08:45 server2 systemd[1]: Failed to start A high performance web server and a reverse proxy server.

The error makes sense but am not sure how to fix it without removing the others lines that I was asked to put in.

No you tried to configure nginx to listen to port 8080. You need to modify openHAB in your Ubuntu launch script.

Hi, sorry to ask a silly question, but can you please point me to a URL that will help me know where to start? I’ve googled openhab launch script but am going in circles.

In /etc/defaults/openhab2 I set OPENHAB_HTTP_ADDRESS=127.0.0.1. I then restarted the service and all is well.