How to change apache port for OpenShift (4.x) deployment?

Hello,

I want to deploy Nextcloud in OpenShift 4.x.
Is there a way how to change the port, where apache runs? The standard image uses 80 as non-root, but to get it running on OpenShift it has to be changed.

Error message:

could not bind to address [::]:80
could not bind to address 0.0.0.0:80 no listening sockets available, shutting down

Idea:

        ports:
          - containerPort: 8443
            protocol: TCP

Complete yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nextcloud-server
  labels:
    app: nextcloud
spec:
  replicas: 1
  selector:
    matchLabels:
      pod-label: nextcloud-server-pod
  template:
    metadata:
      labels:
        pod-label: nextcloud-server-pod
    spec:
      containers:
      - name: nextcloud
        image: nextcloud:apache
        ports:
          - containerPort: 8443
            protocol: TCP
        volumeMounts:
        - name: server-storage
          mountPath: /var/www/html
          subPath: server-data
      volumes:
      - name: server-storage
        persistentVolumeClaim:
          claimName: nextcloud-shared-storage-claim

Any hint is welcome.

Brgds, Marc

You can change apache ports:
https://www.tecmint.com/change-apache-port-in-linux/

Question is for you where you run apache and where the configuration files can be found.

That is not my question. I asked for an improvement in the original Nextcloud image to define another Apache port with specifications. With this, you can then deploy with a different Apache port in Kubernetes/OpenShift without modifying the image.

Brgds
Marc

If you want to create letsencrypt certificates, access Nextcloud from outside on different networks, you should deviate from default ports. A more proper way to solve that is to use different hostnames, e.g. openshift.example.org and nextcloud.example.org. Apache and other servers support this name-based virtual hosting.
https://httpd.apache.org/docs/2.4/vhosts/examples.html

This is the second time you have answered me about something completely different from what I asked for.

It’s not about certificate or other hostnames. It is about the Apache port when deploying the container, which has to be changed by predefined parameters. I don’t see a workaround via postscript or other methods as useful.

Well, I sent you a link to the documentation where you can change the port. Where you find such files in your type of container, I don’t know that. But if you know the file you are looking for, you might be able to find it. I won’t have the time to do that for you.

And regarding this, I just wrote why your request is of special interest

because for many people the SSL certificates are important and they care about accessing their Nextcloud through Hotel or other wifis where non-standard ports are often blocked.

I don’t know who creates this image, you can ask them to add such an option to use different ports.

Thank you for coming.
All your information is helpful, but I have the ambition not to build a custom image.

It’s a known issue and I hope that following enhancement (reason for my post) will be integrated in

Docker

Hi,
to fix the Problem you have to overwrite the 2 Apache config files (000-default.conf & ports.conf) with an ConfigMap in your deployment. Here is an example for that:

apiVersion: v1
kind: ConfigMap
metadata:
  name: nextcloud-config
data:
  000-default.conf: |
    <VirtualHost *:8080>
      DocumentRoot /var/www/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
  ports.conf: |
    Listen 8080

To mount the configs into your deployment you can use this way:

        volumeMounts:
        - name: config-volume
          mountPath: /etc/apache2/sites-available/000-default.conf
          subPath: 000-default.conf
        - name: config-volume
          mountPath: /etc/apache2/ports.conf
          subPath: ports.conf
volumes:
      - name: config-volume
        configMap:
          name: nextcloud-config

For me this way is working on OpenShift 4.13

Regards
Bernd