0

I'm pulling my hair out with the sparse support and documentation for Ubuntu server 15.04. although that's to be expected from a non LTS release.

I have Nginx serving Owncloud, called example.com.conf in sites-available and symlinked to sites-enabled. OwnCloud is served from the same server as NGinx, with validated SSL certs.

The problem I face, and has been puzzling me for days is how to set up NGinx to carry on doing as it is (working with no issues) and reverse proxy a Node.js app running at 192.168.0.24:4000 on the same domain. I want both served on the same domain (i.e. example.com with the Node.js app acting as the / and OwnCloud as /owncloud. From what I can make out Owncloud is doing this itself from its config.php file?

<?php
$CONFIG = array (
  'instanceid' => '***********',
  'passwordsalt' => '***************************',
  'secret' => '****************************************',
  'trusted_domains' => 
   array (
     1 => 'example.com',
   ),
   'datadirectory' => '/shared/owncloud/data',
   'overwrite.cli.url' => 'https://example.com/owncloud',
 ......

I'm guessing the bottom line of text is over writing the URL to /owncloud, as I can find no hint of it in the .conf in sites-available/enabled.

upstream php-handler {
  server 127.0.0.1:9000;
  server unix:/var/run/php5-fpm.sock;
}

server {
  listen 80;
  server_name 192.168.0.23 localhost example.com;
  return 301 https://$server_name$request_uri; # enforce https
}

server {
  listen 443 ssl;
  server_name 192.168.0.23 localhost example.com;

  # Add headers to serve security related headers
  add_header Strict-Transport-Security max-age=15768000;
  add_header X-Content-Type-Options nosniff;
  add_header X-Frame-Options "SAMEORIGIN";
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Robots-Tag none;

  ssl_certificate /etc/nginx/certs/example.crt;
  ssl_certificate_key /etc/nginx/certs/example.key;

  # Path to the root of your installation
  root /var/www/owncloud;
  client_max_body_size 10G; # set max upload size
  fastcgi_buffers 64 4K;

  # ownCloud blacklist
location ~ ^/owncloud/(?:\.htaccess|data|config|db_structure\.xml|README) {
    deny all;
    error_page 403 = /owncloud/core/templates/403.php;
}

location / {
    proxy_pass http://192.168.0.24:4000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

location /owncloud/ {
    error_page 403 = /owncloud/core/templates/403.php;
    error_page 404 = /owncloud/core/templates/404.php;

    rewrite ^/owncloud/caldav(.*)$ /remote.php/caldav$1 redirect;
    rewrite ^/owncloud/carddav(.*)$ /remote.php/carddav$1 redirect;
    rewrite ^/owncloud/webdav(.*)$ /remote.php/webdav$1 redirect;

    rewrite ^(/owncloud/core/doc[^\/]+/)$ $1/index.html;

    # The following rules are only needed with webfinger
    rewrite ^/owncloud/.well-known/host-meta /public.php?service=host-meta last;
    rewrite ^/owncloud/.well-known/host-meta.json /public.php?service=host-meta-json last;
    rewrite ^/owncloud/.well-known/carddav /remote.php/carddav/ redirect;

I've tried everything I can think of to resolve this but can't find a way to serve OwnCloud and a reverse proxy on the same domain. Do I have to have a separate .conf file? I'm stumped.

15
  • What you've got setup in your OwnCloud config file ('overwrite.cli.url' => 'https://example.com/owncloud') needs to be reflected in the configuration of your web server. Right now it's not, you're trying to serve OwnCloud from the root URL as opposed to the /owncloud URL as desired, and nowhere have you told NGinx to proxy anything to Node.js.
    – GregL
    Aug 20, 2015 at 14:35
  • And what happens now, with that config?
    – GregL
    Aug 20, 2015 at 15:23
  • I've save it under example.com.conf in sites available symlinked, to enabled. and it still does the same on NGinx restart. I can reach the node.js app by its real url and port just not from the root of the NGinx server. Aug 20, 2015 at 15:28
  • Try doing one thing at a time: Getting Node.js to work behind Nginx, then adding the OwnCloud portion. Or vice-versa.
    – GregL
    Aug 20, 2015 at 15:40
  • The Owncloud part works fine behind NGInx. its getting the node app to been seen on port 80 at the / of the the same domain. I've even tried removing the 301 redirect to port 443 and placing the location / there. Aug 20, 2015 at 15:45

0

You must log in to answer this question.

Browse other questions tagged .