Repository navigation
503 Error after nextcloud runs a time #237
Copy link
Copy link
Closed
Labels
0. Needs triagePending check for reproducibility or if it fits our roadmapPending check for reproducibility or if it fits our roadmap
Description
Steps to reproduce
- Install nextcloud on Debian 8 with nginx and php5.6
- let it run a time
- change your pc and try to reach nextcloud in chrome => 503: Service not available.
Actual behaviour
When I restart php5-fpm I can access nextcloud at chrome again. I´ve tested it with Firefox also and the same problem. It seems to be that only index.php is affected. When I run other URLs I can access nextcloud.
My php-fpm conf:
[cloud]
listen = /var/run/php5-fpm-cloud.sock
listen.backlog = 65535
listen.allowed_clients = 127.0.0.1
user = cloud
group = cloud
listen.mode = 0660
listen.owner = cloud
listen.group = www-data
pm.process_idle_timeout = 10s
pm.max_requests = 0
pm = dynamic
pm.max_children = 15
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 7
chdir = /
php_admin_value[open_basedir] = /var/kunden/cloud:/usr/share/php5:/tmp:/var/tmp:/dev/urandom:
php_admin_value[disable_functions] = dl,passthru,shell_exec,system,proc_open,popen,show_source
php_admin_value[memory_limit] = 256M
php_admin_value[max_execution_time] = 240
php_admin_value[upload_max_filesize] = 750M
php_admin_value[post_max_size] = 750M
php_admin_value[max_input_time] = 3600
php_admin_value[max_execution_time] = 3600
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
Server configuration
Operating system: Debian 8
Web server: nginx 1.11.1
Database: MariaDB
PHP version: 5.6.22
Nextcloud version: 9.0.5
Updated from an older Nextcloud/ownCloud or fresh install: new install
Where did you install Nextcloud from: nextcloud.com
Signing status (Nextcloud 9.0 and above):
Login as admin user into your Nextcloud and access
http://example.com/index.php/settings/integrity/failed
paste the results here.
errors have been found.
List of activated apps:
If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder
The content of config/config.php:
If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your Nextcloud installation folder
or
Insert your config.php content here
(Without the database password, passwordsalt and secret)
Are you using external storage, if yes which one: local
Are you using encryption: no
Client configuration
Browser: Chrome
Operating system: Windows 7 64bit
Logs
Web server error log
no log
Nextcloud log (data/owncloud.log)
"PHP","message":"Comments starting with '#' are deprecated in Unknown on line 1 at Unknown#0","level":3,"time":"2016-06-27T19:15:20+00:00","method":"PROPFIND","url":"\/remote.php\/webdav\/",
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
0. Needs triagePending check for reproducibility or if it fits our roadmapPending check for reproducibility or if it fits our roadmap
Activity
LukasReschke commentedon Jun 27, 2016
That's the second report I get of this but I still wasn't able to reproduce this locally on my instances. Then again, I only do use Apache. For other NGINX users it works fine though.
Is there any chance you can get me super easy reproduction steps (e.g. a docker container) or access to your machine using SSH (https://github.com/LukasReschke.keys)? That would make it way easier for me to debug this.
aktavor69 commentedon Jun 29, 2016
Hi, its me again, we talking together few days ago
Its pretty easy to reproduce.
If you want, I reproduce my config on a VPS, I will send you credentials.
edit : email sent
LukasReschke commentedon Jun 30, 2016
This is caused by a NGINX setting, the following is documented at https://docs.nextcloud.org/server/9/admin_manual/installation/nginx_owncloud_9x.html:
This will fail hard, if somebody accesses
/directly withoutindex.phpin it then$_SERVER['SCRIPT_NAME']is set to an empty string instead ofindex.php. This can lead to any kind of problems and the NGINX config should probably be addressed for that.For now I'd just recommend to remove that line from your config.
@josh4trunks @mmattel Any idea how the NGINX config could be adjusted to keep this in mind?
benhartwich commentedon Jun 30, 2016
I´ve commented this line out, but have the same error. the owncloud client has a detailled error message: Internal Server error: The Request URI /remote.php/webdav/ did not end with the contents of PATH_INFO(i)
josh4trunks commentedon Jun 30, 2016
@LukasReschke
The line you reference doesn't affect "SCRIPT_NAME" passed to PHP, since that variable is set in fastcgi_params. But it does affect "SCRIPT_FILENAME"
A request for "/" would be matched by the
/block, it does not match the PHP block with the line you reference.It would then be rewritten to "/index.php" > then match the PHP block, which would set the "SCRIPT_FILENAME" to "/index.php"
josh4trunks commentedon Jun 30, 2016
@benhartwich if you comment out that line, alot of aspects of owncloud won't work.
@LukasReschke I don't think you should tell people to remove that line =P
LukasReschke commentedon Jun 30, 2016
https://github.com/nextcloud/server/blob/stable9/lib/base.php#L518 calls IRequest::getScriptName(), this function reads $_SERVER['SCRIPT_NAME']. With the documented NGINX config SCRIPT_NAME is empty when opening / instead of /index.php. (just do a
var_dump($_SERVER);exit();in your index.php)Removing that line from the config sets the proper SCRIPT_NAME. I don't have much experience with NGINX but this seems just wrong. (expected behaviour would be to get "index.php")
josh4trunks commentedon Jun 30, 2016
@LukasReschke A request for "/" would not be passed to PHP. It would first be rewritten to "/index.php"
Please see #237 (comment)
LukasReschke commentedon Jun 30, 2016
@josh4trunks To illustrate the problem, I have created a docker. It is based on the config from https://docs.nextcloud.org/server/9/admin_manual/installation/nginx_examples.html (which is basically a 1:1 copy of the ownCloud docs page)
To test it please execute:
Inside the container start PHP FPM and NGINX:
Now cURL
/index.phpand/directly:As you can see, the index.php is invoked in both but the proper SCRIPT_NAME is only set for the one where the index.php is appended. That's actually the problem that I'm pointing out here.
From a software perspective we do expect to get a proper
$_SERVER['SCRIPT_NAME']for the/URL as well.josh4trunks commentedon Jun 30, 2016
@LukasReschke Can you post/link to the exact nginx config and fastcgi_params so I can take a look.
If it is exactly as the docs, "/" would be internally rewritten to "/index.php" and SCRIPT_NAME would be "/index.php".
Can you also try replacing the index.php with this to confirm SCRIPT_NAME is being set incorrectly.
I can test this as well tonight. Currently running ownCloud but if you are correct this issue would crop up before touching the PHP code.
####EDIT####
Looking at your docker file, looks like you did what I'm thinking. Can you post your fastcgi_params
13 remaining items
MorrisJobke commentedon Jul 1, 2016
@josh4trunks Could we add this to the documentation? Or is this something special to the environment?
josh4trunks commentedon Jul 1, 2016
We should make this change. In default environments this is needed since we rely on rewrite now. It only doesn't affect some if they have something like fastcgi_index set to index.php, while this is common, it is not default.
Change is from...
to...
This needs to be applied to both
https://docs.nextcloud.org/server/9/admin_manual/installation/nginx_owncloud_9x.html#nextcloud-in-the-webroot-of-nginx
https://docs.nextcloud.org/server/9/admin_manual/installation/nginx_owncloud_9x.html#nextcloud-in-a-subdir-of-nginx
Fix order of Nginx config options
MorrisJobke commentedon Jul 1, 2016
@josh4trunks nextcloud/documentation#40 should do the trick then ;)
aktavor69 commentedon Jul 1, 2016
@MorrisJobke Nop, its not right.
You forgot to remove
fastcgi_split_path_info ^(.+\.php)(/.+)$;and add instead
fastcgi_split_path_info ^(.+\.php)(/.*)$;MorrisJobke commentedon Jul 1, 2016
@aktavor69 Thanks a lot. I didn't spot that :( I fixed it :)
Fix order of Nginx config options
MorrisJobke commentedon Jul 22, 2016
This should be fixed with the new Nginx config
Ardakilic commentedon Oct 11, 2016
I had the same issue after migrating from owncloud,
Simply switching the order of these two like this, as described above, fixed the problem for me:
I'm using Debian 8.6, PHP7.0, MariaDB, Nginx 1.10.1. All manual install.
techc0de commentedon Mar 1, 2017
Hi,
I don't meant to re-open this thread, but the NC admin manual have incorrect order of those above two lines. The above solution is verified.
FYI: this error only occur on Android devices that use NextCloud app.
Please update the admin manual.
Thanks.
Fix Nginx config
MorrisJobke commentedon Mar 1, 2017
Our manual is also open source. 😉 Nevertheless I fixed it - see nextcloud/documentation#371
Fix Nginx config
Fix Nginx config