大网数据广告活动
服务器运维问答

NGINX reverse proxy Apache running on port 8080 with owncloud

· 52CE 我爱测

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 tha…

问题原文

原帖链接 · Ryahn · CC BY-SA 3.0

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;

events
{
    worker_connections 768;
    #    multi_accept            on;
}

http
{
    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/"
    </FilesMatch>

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

        <IfModule mod_dav.c>
            Dav off
        </IfModule>

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

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


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


</VirtualHost>

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

已采纳解答

原帖链接 · deagh · CC BY-SA 3.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-08-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。