Questions from trouble getting the UniFi Controller to work on macOS High Sierra + Server (port 8080 in use)

apachehomebrewserver.app

After upgrading from Sierra+Server to High Sierra+Server I am running into the problem that port 8080 is occupied by default. This blocks the UniFi controller from launching.

After the upgrade, I lost all my WebDAV shares, for which the simple solution to get them back was setting Wiki Server on.

But now, httpd is listening on port 8080. nmap tells me:

8080/tcp  open  http-proxy

I wonder, why is this called http-proxy? And lsof:

sudo lsof -i :8080
Password:
COMMAND  PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd   2229 root    4u  IPv6 0xd734a34402fd0c9b      0t0  TCP *:http-alt (LISTEN)
httpd   2238 _www    4u  IPv6 0xd734a34402fd0c9b      0t0  TCP *:http-alt (LISTEN)
httpd   2290 _www    4u  IPv6 0xd734a34402fd0c9b      0t0  TCP *:http-alt (LISTEN)
httpd   2291 _www    4u  IPv6 0xd734a34402fd0c9b      0t0  TCP *:http-alt (LISTEN)
httpd   2291 _www   25u  IPv6 0xd734a343f0761a9b      0t0  TCP foo.rna.nl:http-alt->unifi-foo.rna.nl:40018 (ESTABLISHED)
httpd   2292 _www    4u  IPv6 0xd734a34402fd0c9b      0t0  TCP *:http-alt (LISTEN)
httpd   2293 _www    4u  IPv6 0xd734a34402fd0c9b      0t0  TCP *:http-alt (LISTEN)
httpd   2293 _www   25u  IPv6 0xd734a343f0760f1b      0t0  TCP foo.rna.nl:http-alt->unifi-bar.rna.nl:60849 (ESTABLISHED)

The Apache server creates these httpd daemons:

sysbh$ ps laxww|grep 2229
    0  2229     1   0  20  0  4280200   6592 -      Ss     ??    0:00.35 /usr/sbin/httpd -D SERVER_APP_HAS_DEFAULT_PORTS -D FOREGROUND
    0  2236  2229   0  20  0  4289980  15012 -      S      ??    0:00.65 /usr/bin/ruby /usr/libexec/wfs/webdavsharing_mapper
   70  2238  2229   0  20  0  4284820   3520 -      S      ??    0:00.13 /usr/sbin/httpd -D SERVER_APP_HAS_DEFAULT_PORTS -D FOREGROUND
   70  2290  2229   0  20  0  4280200   2444 -      S      ??    0:00.10 /usr/sbin/httpd -D SERVER_APP_HAS_DEFAULT_PORTS -D FOREGROUND
   70  2291  2229   0  20  0  4280200   2508 -      S      ??    0:00.12 /usr/sbin/httpd -D SERVER_APP_HAS_DEFAULT_PORTS -D FOREGROUND
   70  2292  2229   0  20  0  4284820   3496 -      S      ??    0:00.13 /usr/sbin/httpd -D SERVER_APP_HAS_DEFAULT_PORTS -D FOREGROUND
   70  2293  2229   0  20  0  4280200   2472 -      S      ??    0:00.11 /usr/sbin/httpd -D SERVER_APP_HAS_DEFAULT_PORTS -D FOREGROUND
  501  3418   711   0  31  0  4258468     24 -      R+   s001    0:00.00 grep 2229

And apparently, they listen on port 8080 because /etc/apache2/httpd.conf has:

<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
    Listen 8080
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
    Listen 80
</IfDefine>

I wonder if mainly it is safe to change 8080 into 8081 there so the web server doesn't clash with the UniFi controller anymore.

It also seems it httpd getting the "-D SERVER_APP_HAS_DEFAULT_PORTS" from /etc/apache2/env.plist via the httpd-wrapper ruby script (which is actually started by the LaunchDaemon)and I was wondering how env.plist gets there.

And I was wondering where the simple page comes from that just has a h1 tag with the text "It works!" when I go to http://localhost:8080/

Note: I have an nginx running (installed with homebrew) but I have turned 8080 off on that install and httpd is running on 8080 even if nginx is not running. However, it is in Homebrew that I find references to "It works!" so far.

Best Answer

Yes, you can safely change the port in

/etc/apache2/httpd.conf 

and the default page with "It works!" comes from

/Library/WebServer/Documents