I have nginx running as my main webserver. I have installed owncloud with apache running on port 8080. I know that owncloud has unofficial community support for nginx but I prefer to keep official support.

My current issue is that, the reverse proxy doesnt seem to be working as intended. It keeps loading my default website. My website runs through cloudflare with flexible SSL cert for HTTPS.

However, I can go to xxx.xxx.xxx.xxx:8080 and access owncloud directly.

Main nginx config

user www-data;

worker_processes 2;
worker_rlimit_nofile 20480;

pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

    worker_connections 768;
    #    multi_accept            on;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 15;
    types_hash_max_size 2048;
    server_tokens off;

    #    log_format            main '$remote_addr - $remote_user [$time_local] "$request" $status  $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
    log_format main 'xx.xx.xx.xx - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "xx.xx.xx.xx"';

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    access_log /var/log/nginx/access.log main;
    error_log /var/log/nginx/error.log;

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    proxy_cache_path /tmp/nginx-filecache levels=1:2 keys_zone=FILES:10m inactive=7d max_size=800g;

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;


Nginx config for apache

server {
    listen 80;
    listen 443 ssl;
    server_name gomn.net;

    root /var/www/owncloud;
    index index.php index.htm index.html;

    location / {
        try_files $uri $uri/ /index.php;

    location ~ \.php$ {
        proxy_pass http://localhost:8080;
        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;

    location ~ /\. {
        deny all;

This is my apache config for owncloud

<VirtualHost *:8080>

    DocumentRoot /var/www/owncloud
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost/"

    <Directory /var/www/owncloud/>
        Options +FollowSymlinks
        AllowOverride All

        <IfModule mod_dav.c>
            Dav off

        SetEnv HOME /var/www/owncloud
        SetEnv HTTP_HOME /var/www/owncloud

    <Directory /var/www/owncloud/data/*/>
        Allow from None
        Order allow,deny

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

When Nginx is your main webserver, why do you use Apache? Owncloud does run fine with Nginx (without Apache).

You have to configure Nginx to use your Apache as upstream and not within your .php location.

Try something like:

upstream owncloud {
  server localhost:8080;

server {
  location / {
    proxypass http://owncloud;

For more information see nginx upstream documentation

| improve this answer | |
  • Thank you. As for not running owncloud on nginx. I was having issues with the post installation. I wasnt able to get support due to it being on nginx. – Ryahn Aug 8 '17 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.