[How-To] ownCloud using NGINX, PHP-FPM, and MySQL

Rickle

Dabbler
Joined
Aug 14, 2013
Messages
38
Hey there,
i have followed your tutorial and successfully installed owncloud in a portjail.
thank you Cyberjock as well for https tutorial (i was fortunate and did not have to re-compile NginX for ssl support)
i have added Fail2Ban and IPFW to help secure the installation and have added a tutorial for those that wish to follow it.
i linked my tutorial to yours. Joshua, if thats ok with you.
it can be seen here

Thank you very much for the awsome tutorial
 

Paulo

Dabbler
Joined
Dec 22, 2013
Messages
17
Getting this error when accessing the post setup check (http://<url>/owncloud/index.php/post-setup-check):
Code:
Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.
Please double check the installation guides.

here's the log:
Code:
{"app":"PHP","message":"simplexml_load_string(): Entity: line 48: parser error : Opening and ending tag mismatch: meta line 14 and head at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): \t\t\t&lt;\/head&gt; at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): \t\t\t      ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): Entity: line 72: parser error : Opening and ending tag mismatch: meta line 13 and html at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): &lt;\/html&gt; at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string():        ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): Entity: line 73: parser error : Premature end of data in tag head line 9 at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string():  at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): Entity: line 73: parser error : Premature end of data in tag html line 7 at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string():  at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"core","message":"isWebDAVWorking: NO - Reason: The passed data is not valid XML (InvalidArgumentException)","level":2,"time":"2014-03-17T21:12:46+00:00"}


and the source of the file (i think) it's looking at (/owncloud/remote.php/webdav):
Code:
<html>
<head>
  <title>Index for / - SabreDAV 1.7.6-stable</title>
  <style type="text/css">
  body { Font-family: arial}
  h1 { font-size: 150% }
  </style>
        <link rel="shortcut icon" href="/owncloud/remote.php/webdav/?sabreAction=asset&assetName=favicon.ico" type="image/vnd.microsoft.icon" /></head>
<body>
  <h1>Index for /</h1>
  <table>
    <tr><th width="24"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>
    <tr><td colspan="5"><hr /></td></tr><tr><td colspan="5"><hr /></td></tr></table>
        <address>Generated by SabreDAV 1.7.6-stable (c)2007-2013 <a href="http://code.google.com/p/sabredav/">http://code.google.com/p/sabredav/</a></address>
        </body>
        </html>
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Getting this error when accessing the post setup check (http://<url>/owncloud/index.php/post-setup-check):
Code:
Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.
Please double check the installation guides.

here's the log:
Code:
{"app":"PHP","message":"simplexml_load_string(): Entity: line 48: parser error : Opening and ending tag mismatch: meta line 14 and head at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): \t\t\t&lt;\/head&gt; at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): \t\t\t      ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): Entity: line 72: parser error : Opening and ending tag mismatch: meta line 13 and html at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): &lt;\/html&gt; at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string():        ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): Entity: line 73: parser error : Premature end of data in tag head line 9 at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string():  at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): Entity: line 73: parser error : Premature end of data in tag html line 7 at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string():  at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"PHP","message":"simplexml_load_string(): ^ at \/usr\/local\/www\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#533","level":3,"time":"2014-03-17T21:12:46+00:00"}
{"app":"core","message":"isWebDAVWorking: NO - Reason: The passed data is not valid XML (InvalidArgumentException)","level":2,"time":"2014-03-17T21:12:46+00:00"}


and the source of the file (i think) it's looking at (/owncloud/remote.php/webdav):
Code:
<html>
<head>
  <title>Index for / - SabreDAV 1.7.6-stable</title>
  <style type="text/css">
  body { Font-family: arial}
  h1 { font-size: 150% }
  </style>
        <link rel="shortcut icon" href="/owncloud/remote.php/webdav/?sabreAction=asset&assetName=favicon.ico" type="image/vnd.microsoft.icon" /></head>
<body>
  <h1>Index for /</h1>
  <table>
    <tr><th width="24"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>
    <tr><td colspan="5"><hr /></td></tr><tr><td colspan="5"><hr /></td></tr></table>
        <address>Generated by SabreDAV 1.7.6-stable (c)2007-2013 <a href="http://code.google.com/p/sabredav/">http://code.google.com/p/sabredav/</a></address>
        </body>
        </html>
I believe this is a false error that is always present with nginx. you can try browsing the a WebDAV URL and it should work.
 

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
These tutorials are fantastic, got ownCloud set up, thanks to Joshua and https cyberjock, works almost perfectly, however, cyberjock's config he uploaded doesn't work, I got a blank page, didn't say it didn't load, just blank. So I used Joshua's with Cyberjock's edits. I would love to know how I can change the config in nginx to redirect http to https so i can to to http://ip/owncloud or even just type ip/owncloud in the url bar and it'll redirect to https://ip/owncloud. Thanks in advance guys! Loved it, so much quicker than the pbi, would be awesome if they changed to pbi to use a setup similar to this.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
These tutorials are fantastic, got ownCloud set up, thanks to Joshua and https cyberjock, works almost perfectly, however, cyberjock's config he uploaded doesn't work, I got a blank page, didn't say it didn't load, just blank. So I used Joshua's with Cyberjock's edits. I would love to know how I can change the config in nginx to redirect http to https so i can to to http://ip/owncloud or even just type ip/owncloud in the url bar and it'll redirect to https://ip/owncloud. Thanks in advance guys! Loved it, so much quicker than the pbi, would be awesome if they changed to pbi to use a setup similar to this.
You could easily do this in NGINX with a 'return 301 https://etc...' but I suggest you just force https for owncloud in the config. You may need to make sure the HTTPS header is passed down to php. I use a different setup for HTTPS so not sure what changes need to be made to make sure PHP is passed the header.

/usr/local/www/owncloud/config/config.php
Code:
"forcessl" => true,
 

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
You could easily do this in NGINX with a 'return 301 https://etc...' but I suggest you just force https for owncloud in the config. You may need to make sure the HTTPS header is passed down to php. I use a different setup for HTTPS so not sure what changes need to be made to make sure PHP is passed the header.

/usr/local/www/owncloud/config/config.php
Code:
"forcessl" => true,

I already have ownCloud forcing https, but if I go to http it just can't connect
I've never really used nginx before, nor managed a server so I'm not super skilled with a terminal, I can work my way around, but I'm horrible with configs. Maybe cyberjock might be able to give some insight
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
I playing with the ownCloud instance today, and I noticed if i try to access it through http it'll redirect me to the https version, but to the internal ip, which obviously won't work over the internet, but if I go straight to https it won't redirect to the internal IP. Any way to configure nginx or ownCloud to redirect to https with the hostname instead of the internal ip?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I playing with the ownCloud instance today, and I noticed if i try to access it through http it'll redirect me to the https version, but to the internal ip, which obviously won't work over the internet, but if I go straight to https it won't redirect to the internal IP. Any way to configure nginx or ownCloud to redirect to https with the hostname instead of the internal ip?
did you actually test if it redirects to the external IP when accessing non-locally? I usually test this on my smartphone after disconnecting from WiFi.

sounds like php is receiving the wrong host header or owncloud is set to overwrite the host. I'd start by making a php test file that echo's the host header value
 

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
did you actually test if it redirects to the external IP when accessing non-locally? I usually test this on my smartphone after disconnecting from WiFi.

sounds like php is receiving the wrong host header or owncloud is set to overwrite the host. I'd start by making a php test file that echo's the host header value

I did check it with my phone off of the wifi, still attempted to redirect to the local ip. Unfortunately I don't know any PHP (or any programming for that matter at the moment) to write a test file :\
 

Rickle

Dabbler
Joined
Aug 14, 2013
Messages
38
I did check it with my phone off of the wifi, still attempted to redirect to the local ip. Unfortunately I don't know any PHP (or any programming for that matter at the moment) to write a test file :\

Just out of curiosity, are you doing port forwarding to your server from the internet.

Sent from my Nexus 4 using Tapatalk
 

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
Just out of curiosity, are you doing port forwarding to your server from the internet.

Sent from my Nexus 4 using Tapatalk

I believe so, not 100% positive what you meant by that, but I have ports 80 and 443 redirecting to the owncloud jail IP from my firewall
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I did check it with my phone off of the wifi, still attempted to redirect to the local ip. Unfortunately I don't know any PHP (or any programming for that matter at the moment) to write a test file :\

/usr/local/www/owncloud/test.php
Code:
<?php
phpinfo();
?>

Browse to http://NetworkIP/owncloud/test.php
All the headers your client is send or at least php is recieving will show there. If you see an internal IP then you need to make sure passed the right 'host' header to php.
 

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
/usr/local/www/owncloud/test.php
Code:
<?php
phpinfo();
?>

Browse to http://NetworkIP/owncloud/test.php
All the headers your client is send or at least php is recieving will show there. If you see an internal IP then you need to make sure passed the right 'host' header to php.

Thanks, that showed it. This is what I got looking through the php info
Code:
_SERVER["REMOTE_ADDR"]    192.168.1.1
_SERVER["REMOTE_PORT"]    60320
_SERVER["SERVER_ADDR"]    192.168.1.52
_SERVER["SERVER_PORT"]    443
_SERVER["SERVER_NAME"]    no value
_SERVER["REDIRECT_STATUS"]    200
_SERVER["HTTP_HOST"]    <mydomain>.com
_SERVER["HTTP_CONNECTION"]    keep-alive
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Thanks, that showed it. This is what I got looking through the php info
Code:
_SERVER["REMOTE_ADDR"]    192.168.1.1
_SERVER["REMOTE_PORT"]    60320
_SERVER["SERVER_ADDR"]    192.168.1.52
_SERVER["SERVER_PORT"]    443
_SERVER["SERVER_NAME"]    no value
_SERVER["REDIRECT_STATUS"]    200
_SERVER["HTTP_HOST"]    <mydomain>.com
_SERVER["HTTP_CONNECTION"]    keep-alive


Looking at https://github.com/owncloud/core/blob/master/lib/private/request.php#L68 it should be using HTTP_HOST, not sure why it's redirecting for you.
  • Is 'HTTP_X_FORWARDED_HOST' on the phpinfo page anywhere?
  • Can you show the variables output from your phone?
  • can you check if 'overwritehost' is in /usr/local/www/owncloud/config/config.php
 

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
Looking at https://github.com/owncloud/core/blob/master/lib/private/request.php#L68 it should be using HTTP_HOST, not sure why it's redirecting for you.
  • Is 'HTTP_X_FORWARDED_HOST' on the phpinfo page anywhere?
  • Can you show the variables output from your phone?
  • can you check if 'overwritehost' is in /usr/local/www/owncloud/config/config.php
HTTP_X_FORWARDED_HOST was not on the phpinfo page and overwritehost wasn't in the config file either
Phone php variables output: I just used a screenshot, copying and pasting text came out too sloppy
MLsbG2I.png
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
The header PHP is receiving is correct. Did you check the config for that line. Otherwise, I'm stumped, and you should ask on the owncloud forum.
 

Aubury

Dabbler
Joined
Mar 27, 2014
Messages
15
I seem to have fixed it haha I changed
Code:
 
  'trusted_domains' =>
   array (
    0 => '192.168.1.52',
  ),

to
Code:
  'trusted_domains' =>
  array (
    0 => '<mydomain>.com',
  ),

at the top of config.php, worked on my phone with wifi off. Not sure if it's the right way to do it, but it worked haha
 
Top