Let nextcloud listen on one IP address only

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 24.04
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.25
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • none
  • PHP version (e.g, 8.3):
    • 8.3
  • Is this the first time you’ve seen this error? (Yes / No):
    • no always
  • When did this problem seem to first start?
    • right after insallation
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare metal as part of ubuntu server
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

My new server has 2 ip adresses. On one of those I want to run NC. On the other another HTTP:80 service. I want NC to respond only on one of 2 ip addresses.

This works perfectly fine on the old server. Nextcloud does not claim the second I address there

Steps to replicate it (hint: details matter!):

  1. Install from scratch ubuntu server with nextcloud (snap) as option selected

  2. Add an additional IP with Netplan

  3. Try to limit NC to only one IP address

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

No log

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

Irrelevant

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

Includes Apache in the snap

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "apps_paths": [
            {
                "path": "\/snap\/nextcloud\/current\/htdocs\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/snap\/nextcloud\/current\/nextcloud\/extra-apps",
                "url": "\/extra-apps",
                "writable": true
            }
        ],
        "supportedDatabases": [
            "mysql"
        ],
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0
        },
        "log_type": "file",
        "logfile": "\/var\/snap\/nextcloud\/current\/logs\/nextcloud.log",
        "logfilemode": 416,
        "maintenance_window_start": 1,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.2.120"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "32.0.2.2",
        "overwrite.cli.url": "http:\/\/192.168.2.120",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "config_preset": 2,
        "app_install_overwrite": [
            "maps"
        ],
        "maintenance": false
    }
}

Apps

The output of occ app:list (if possible).
Enabled:

  • activity: 5.0.0-dev.0
  • app_api: 32.0.0
  • bruteforcesettings: 5.0.0-dev.0
  • calendar: 6.1.2
  • circles: 32.0.0
  • cloud_federation_api: 1.16.0
  • comments: 1.22.0
  • contacts: 8.1.2
  • contactsinteraction: 1.13.1
  • dashboard: 7.12.0
  • dav: 1.34.2
  • federatedfilesharing: 1.22.0
  • federation: 1.22.0
  • files: 2.4.0
  • files_downloadlimit: 5.0.0-dev.0
  • files_pdfviewer: 5.0.0-dev.0
  • files_reminders: 1.5.0
  • files_sharing: 1.24.1
  • files_trashbin: 1.22.0
  • files_versions: 1.25.0
  • firstrunwizard: 5.0.0-dev.0
  • gpxpod: 7.2.1
  • guests: 4.6.0
  • integration_giphy: 2.2.0
  • logreader: 5.0.0-dev.0
  • lookup_server_connector: 1.20.0
  • mail: 5.6.5
  • nextcloud_announcements: 4.0.0-dev.0
  • notes: 4.12.4
  • notifications: 5.0.0-dev.0
  • oauth2: 1.20.0
  • password_policy: 4.0.0-dev.0
  • photos: 5.0.0-dev.1
  • privacy: 4.0.0-dev.0
  • profile: 1.1.0
  • provisioning_api: 1.22.0
  • recommendations: 5.0.0-dev.0
  • related_resources: 3.0.0-dev.0
  • richdocuments: 9.0.2
  • richdocumentscode: 25.4.702
  • serverinfo: 4.0.0-dev.0
  • settings: 1.15.1
  • sharebymail: 1.22.0
  • spreed: 22.0.7
  • support: 4.0.0-dev.0
  • survey_client: 4.0.0-dev.0
  • systemtags: 1.22.0
  • text: 6.0.1
  • theming: 2.7.0
  • twofactor_backupcodes: 1.21.0
  • user_status: 1.12.0
  • viewer: 5.0.0-dev.0
  • weather_status: 1.12.0
  • webhook_listeners: 1.3.0
  • whiteboard: 1.5.0
  • workflowengine: 2.14.0
    Disabled:
  • admin_audit: 1.22.0
  • encryption: 2.20.0
  • files_external: 1.24.0
  • suspicious_login: 10.0.0-dev.0
  • twofactor_nextcloud_notification: 6.0.0-dev.0
  • twofactor_totp: 14.0.0
  • user_ldap: 1.23.0

Tips for increasing the likelihood of a response

  • Use the preformatted text formatting option in the editor for all log entries and configuration output.
  • If screenshots are useful, feel free to include them.
    • If possible, also include key error output in text form so it can be searched for.
  • Try to edit log output only minimally (if at all) so that it can be ran through analyzers / formatters by those trying to help you.

What is listening on port 80/443

ss -lntp | grep -E ':(80|443)\b'

If you see 0.0.0.0:80, *:80, or [::]:80, then:

Apache: bind to a specific IP (instead of *:80)

Important: remove/replace generic Listen 80 / Listen 443.

Example /etc/apache2/ports.conf:

# nextcloud ip
Listen 192.168.2.120:80
Listen 192.168.2.120:443
# other IP
Listen 192.168.2.130:80

Nextcloud vhost only on the Nextcloud IP:

<VirtualHost 192.168.2.120:80>
  ServerName cloud.example.com
  Redirect permanent / https://cloud.example.com/
</VirtualHost>

<VirtualHost 192.168.2.120:443>
  ServerName cloud.example.com
  DocumentRoot /var/www/nextcloud
  # SSL config...
</VirtualHost>

Other HTTP service only on the second IP:

<VirtualHost 192.168.2.130:80>
  ServerName other.example.com
  DocumentRoot /var/www/other
</VirtualHost>

Apply:

apachectl -t
systemctl reload apache2

h.t.h.


ernolf

Hey @WoodhouseZB, welcome to the Nextcloud community and thanks for supporting Nextcloud snap :handshake:

Sorry to hear you are having issues with your Nextcloud snap installation. If you’ve come this far, you’re on the right track! There is a good chance someone in the community has had a similar issue and knows how to resolve it. That depends on how you request assistance. So read your request for tone, avoiding hyperbole and assuming good intentions.

Below are some links to how-to’s answering frequently asked questions and may help you help yourself;

For your use case its recommended to put the snap behind a reverse proxy, see
Reverse proxy configuration

Similar request has is being discussed here:

it would be great if you added your thumbs-up

Hi Ernolf. I am running the snap version and do not appear to have any config for Apache in /etc/, so my situation may require a different solution. I may be wrong..