ONLYOFFICE / docker-onlyoffice-nextcloud

MIT License
375 stars 157 forks source link

custom nextcloud location url #11

Open basheuvelink opened 5 years ago

basheuvelink commented 5 years ago

Is it possible to customize nginx.conf in a matter so you could open nextcloud at a custom location? For example: http://localhost/nextcloud instead of http://localhost

Thanks!

flaminestone commented 5 years ago

Hello @basheuvelink. Yes, it is possible. At first, you should change proxy configuration and then set virtual path to special nextcloud option - overwritewebroot.

part of nginx settings:

        location /nextcloud/ {
                proxy_pass_header   Server;
                proxy_set_header    Host $host;
                proxy_set_header    X-Real-IP $remote_addr;
                proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header    X-Forwarded-Proto $scheme;
                proxy_pass          http://nextcloud/;
        }

nextcloud config.php

<?php
$CONFIG = array (
<..some configs..>,
  'overwritewebroot' => 'nextcloud'
);

See documentation

basheuvelink commented 5 years ago

Hero! Many thanks in advance! I'm a little bit noobish - just started with ubuntu -

Since nextcloud is running in docker, I can access the container files using docker-compose exec. Any ideas how to edit the config.php?

flaminestone commented 5 years ago
docker exec -it nextcloud_container_id bash
apt update && apt install -y nano
nano config/config.php
basheuvelink commented 5 years ago

I'm getting there.. Modified the config.php succesfully. Also added location to nginx.conf. Now when opening the 'new' Url i get 502 Bad Gateway nginx/1.15.8. I guess the proxy_pass value isn't correct. I refer here to the app-server running in docker. How do I find the good reference for the nextcloud server?

flaminestone commented 5 years ago

Can you show nginx settings and config.php settings?

basheuvelink commented 5 years ago

Here the config.php config.php.txt

basheuvelink commented 5 years ago

Here the nginx.conf nginx.conf.txt

flaminestone commented 5 years ago

I see, you added my example part of nginx settings, but you don't changed path to nextcloud. Please, change http://nextcloud/ to your real nextcloud path (I think, it is home.mynetgear.com)

flaminestone commented 5 years ago

You use docker compose from https://github.com/ONLYOFFICE/docker-onlyoffice-nextcloud?

basheuvelink commented 5 years ago

Yes, exactly that one.

basheuvelink commented 5 years ago

Let me clarify my problem, from an end-user perspective: I want nextcloud available at my URL: home.mynetgear.com/nextcloud I don't want it available at home.mynetgear.com

So in your solution I think I only need to now the exact server name, internally, to refer to the nextcloud service.

basheuvelink commented 5 years ago

Okay I've been trying some things, no luck still. Funny thing though I've managed it untill so far: when I open the URL for my host http://home.mynetgear/nextcloud it redirects it to the correct pages, adding /index.php/apps/files/ in the process, but then the page remains blank. I've added the config.php and nginx.conf for this configuration.

config.php.txt nginx.conf.txt

Also I tried to change the install directory in the docker-compose.yml file, changing the directory of the nextcloud volume with extension /nextcloud (so app_data:/var/www/html/nextcloud). This seems to break it down even more, also with the added location values in config.php.

Hope you have some more thoughts! Thanks anyway

flaminestone commented 5 years ago

@basheuvelink, I tried to find an easy way for making proxy via nginx.conf from this repo, but it is not possible. I think, nextcloud proxy setting is a question for nextcloud community. Maybe, you can find answear there. If you want to change nextcloud root path, you need to rewrite all nginx config. See this

basheuvelink commented 5 years ago

That's too bad! Thanks for the documentation. Can't believe it's that difficult in nginx compared to apache2.

basheuvelink commented 5 years ago

I managed to pull it off eventually! Basically had to move the files from the /var/www/html dir to a subdir and implemented parts of the code as suggested in your last post to the nginx.conf.

flaminestone commented 5 years ago

@basheuvelink, yes, I tried to do it too, but I have some errors after it. Can you show your result nginx config?

basheuvelink commented 5 years ago

@flaminestone , these are my configs:

config.php.txt docker-compose.yml.txt nginx.conf.txt