OwnCloud need help changing the listening port!

Newbie here

I’m running a Raspi 4 with Diet PI - I setup Owncloud, Certbot, and NOIP.

When I build out Owncloud I have 443 and 80 set as the port so for example when I got to my browser 10.10.10.143:443/owncloud as https is configured. How can I change the port for 443 / 80 to something else, as I’m now having issue with Cloudflare because that port is taken.

Any help or direction would be gladly appreciated as I’ve been banging my head on the wall trying to figure it out.

root@DietPi:~# nano /etc/lighttpd/lighttpd.conf
root@DietPi:~# ls
Desktop  noip  noip-2.1.9-1  noip-duc-linux.tar.gz  noip-duc-linux.tar.gz.1
root@DietPi:~# ls -la /etc/lighttpd/conf-{available,enabled}
/etc/lighttpd/conf-available:
total 136
drwxr-xr-x 2 root root 4096 Oct 21 04:48 .
drwxr-xr-x 4 root root 4096 Nov  3 05:40 ..
-rw-r--r-- 1 root root  919 Feb 12  2021 05-auth.conf
-rw-r--r-- 1 root root  725 Feb 12  2021 05-setenv.conf
-rw-r--r-- 1 root root   91 Feb 12  2021 10-accesslog.conf
-rw-r--r-- 1 root root  396 Feb 12  2021 10-cgi.conf
-rw-r--r-- 1 root root   63 Feb 12  2021 10-dir-listing.conf
-rw-r--r-- 1 root root   36 Feb 12  2021 10-evasive.conf
-rw-r--r-- 1 root root  128 Feb 12  2021 10-evhost.conf
-rw-r--r-- 1 root root  104 Feb 12  2021 10-expire.conf
-rw-r--r-- 1 root root  177 Feb 12  2021 10-fastcgi.conf
-rw-r--r-- 1 root root   42 Feb 12  2021 10-flv-streaming.conf
-rw-r--r-- 1 root root   82 Feb 12  2021 10-no-www.conf
-rw-r--r-- 1 root root  849 Feb 12  2021 10-proxy.conf
-rw-r--r-- 1 root root  176 Feb 12  2021 10-rewrite.conf
-rw-r--r-- 1 root root  253 Feb 12  2021 10-rrdtool.conf
-rw-r--r-- 1 root root  398 Feb 12  2021 10-simple-vhost.conf
-rw-r--r-- 1 root root  449 Feb 12  2021 10-sockproxy.conf
-rw-r--r-- 1 root root   99 Feb 12  2021 10-ssi.conf
-rw-r--r-- 1 root root  353 Feb 12  2021 10-ssl.conf
-rw-r--r-- 1 root root  460 Feb 12  2021 10-status.conf
-rw-r--r-- 1 root root  450 Feb 12  2021 10-userdir.conf
-rw-r--r-- 1 root root   38 Feb 12  2021 10-usertrack.conf
-rw-r--r-- 1 root root  168 Feb 12  2021 11-extforward.conf
-rw-r--r-- 1 root root  355 Feb 12  2021 15-fastcgi-php-fpm.conf
-rw-r--r-- 1 root root  319 Oct 10  2021 15-fastcgi-php.conf
-rw-r--r-- 1 root root 2146 Nov  2  2021 50-dietpi-https.conf
-rw-r--r-- 1 root root  508 Feb 12  2021 90-debian-doc.conf
-rw-r--r-- 1 root root  134 Nov  2  2021 98-dietpi-hsts.conf
-rw-r--r-- 1 root root  221 Nov  2  2021 98-dietpi-https_redirect.conf
-rw-r--r-- 1 root root  185 Oct 10  2021 99-dietpi-dav_redirect.conf
-rw-r--r-- 1 root root 1010 Oct 10  2021 99-dietpi-owncloud.conf
-rw-r--r-- 1 root root  162 Feb 12  2021 99-unconfigured.conf
-rw-r--r-- 1 root root  843 Feb 12  2021 README

/etc/lighttpd/conf-enabled:
total 8
drwxr-xr-x 2 root root 4096 Nov  2  2021 .
drwxr-xr-x 4 root root 4096 Nov  3 05:40 ..
lrwxrwxrwx 1 root root   33 Oct 10  2021 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf
lrwxrwxrwx 1 root root   33 Oct 10  2021 10-rewrite.conf -> ../conf-available/10-rewrite.conf
lrwxrwxrwx 1 root root   37 Oct 10  2021 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf
lrwxrwxrwx 1 root root   38 Nov  2  2021 50-dietpi-https.conf -> ../conf-available/50-dietpi-https.conf
lrwxrwxrwx 1 root root   37 Nov  2  2021 98-dietpi-hsts.conf -> ../conf-available/98-dietpi-hsts.conf
lrwxrwxrwx 1 root root   47 Nov  2  2021 98-dietpi-https_redirect.conf -> ../conf-available/98-dietpi-https_redirect.conf
lrwxrwxrwx 1 root root   45 Oct 10  2021 99-dietpi-dav_redirect.conf -> ../conf-available/99-dietpi-dav_redirect.conf
lrwxrwxrwx 1 root root   41 Oct 10  2021 99-dietpi-owncloud.conf -> ../conf-available/99-dietpi-owncloud.conf
lrwxrwxrwx 1 root root   38 Oct 10  2021 99-unconfigured.conf -> ../conf-available/99-unconfigured.conf
root@DietPi:~# nano /conf-available/99-dietpi-owncloud.conf
root@DietPi:~# cat /etc/lighttpd/lighttpd.conf
server.modules = (
        "mod_indexfile",
        "mod_setenv",
        "mod_access",
        "mod_alias",
        "mod_redirect",
)

server.document-root = "/var/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80

# features
#https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_feature-flagsDetails
server.feature-flags       += ("server.h2proto" => "enable")
server.feature-flags       += ("server.h2c"     => "enable")
server.feature-flags       += ("server.graceful-shutdown-timeout" => 5)
#server.feature-flags       += ("server.graceful-restart-bg" => "enable")

# strict parsing and normalization of URL for consistency and security
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails
# (might need to explicitly set "url-path-2f-decode" = "disable"
#  if a specific application is encoding URLs inside url-path)
server.http-parseopts = (
  "header-strict"           => "enable",# default
  "host-strict"             => "enable",# default
  "host-normalize"          => "enable",# default
  "url-normalize-unreserved"=> "enable",# recommended highly
  "url-normalize-required"  => "enable",# recommended
  "url-ctrls-reject"        => "enable",# recommended
  "url-path-2f-decode"      => "enable",# recommended highly (unless breaks app)
 #"url-path-2f-reject"      => "enable",
  "url-path-dotseg-remove"  => "enable",# recommended highly (unless breaks app)
 #"url-path-dotseg-reject"  => "enable",
 #"url-query-20-plus"       => "enable",# consistency in query string
)

index-file.names            = ( "index.php", "index.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
include "/etc/lighttpd/conf-enabled/*.conf"

#server.compat-module-load   = "disable"
server.modules += (
        "mod_dirlisting",
        "mod_staticfile",

You would have to change the ports on the webserver that is hosting up the owncloud services…that would be in the conf file for that particular webservice

Looks like you are using lighttpd so it should be
/etc/lighttpd/lighttpd.conf

Somewhere in there it should refer to the ports

server.document-root = “/var/www”
server.upload-dirs = ( “/var/cache/lighttpd/uploads” )
server.errorlog = “/var/log/lighttpd/error.log”
server.pid-file = “/run/lighttpd.pid”
server.username = “www-data”
server.groupname = “www-data”
server.port = 80 

once change, restart lighttpd

Thank you!

So would this work? server.port = 8033:80 4436:443

No, you can just define one port with server.port.
SSL config is stored in /etc/lighttpd/conf_enabled/50-dietpi-https.conf.

If you want lighttpd to listen on multiple ports, you can do this with an entry like:

$SERVER["socket"] == "mydomain:8080" {
        server.document-root = "/var/www" 
}

If you want to redirect from port 80 to your listening port, you need to use mod_proxy.
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModProxy

What app exactly you are running that tries to bind to port 80/443?

Btw: usually Certbot require web server on port 80 to be able to refresh your certificate. Means if you change web server port, Certbot will not be able to finalize the DNS challenge against your domain.

I built out Owncloud on a Rasp PI using the standard DietPi config - I have since build out a couple of Rapi PI running Docker and Portainer- I’m trying to setup Cloudflare and Nginx so I can so I can use some of these service outside my internal network, however I’m having conflicts when trying to do this with Cloudflare and Owncloud as Owncloud is taking ports 80:443 - So I was trying to free up those ports.

I hope that makes sense.

Looking for any suggestions on how to best approach this.

Did you think of using a reverse proxy? Because this would make your life easier if you like to connect to multiple services using the same DDNS + https.

As stated above, just moving Owncloud on different ports will cause other challenges like losing possible to renew certificate for onwcloud web server.

Using a reverse proxy could take the whole certificate and SSL handling and all services could become available on the same port 80/443. At least as long as all apps could be reached by subpath.

That looks like how you would tell docker to port map…won’t work with a natively installed lighthttp setup

What would be the best way to change the ports or approach this. I’ll but you a case of beer for the help :slight_smile:

Hi Jouliar, this is exactly what I’m trying to do and how I ran into this issue. I’m trying to use NGINX with Cloudflare to setup a reverse proxy however Owncloud is already using port 80/443. So when I tried setting up Nginx and Cloudflare I’m getting a certificate error that points to Cloudflare. That is why I was trying to change the ports on Cloudfare.
Unless I have something misconfigured with Nginx and Clouflare. I was under the impression you could only use one port for one service and Owncloud is already using those ports.

Ok let’s start from the beginning. First remove certificate and HTTPS configuration from owncloud. This is not needed anymore as the proxy will take care on HTTPS/ SSL handling. Once done we will move owncloud to port 8080. As a docker proxy I recommend using NginxProxyManager (NPM). I can give you a command to start it quite easily. Same I’m using at home.

How do I go about removing the cert and if I do that then i’ll nolomnger be able to access Owncloud VIA Https correct?

Below screenshot are examples, when I turnj of port forwating for 443 for ownclound I can get to Porkbun where my domain is hosted VIA NGINX proxy - Still ahven’t gotten an SSL cert worked out.

If I reeanable that port for Owncloud i can access it via https but with it enable if I try accessing NGINX i get the below certificate error and a plceholder page.

Just to confirm, you are running lighttpd correct?