我目前正在运行我们自己的 Owncloud(版本 9)。我已经使用 Apache 做过几次了,但在使用 Nginx 作为代理进行配置时遇到了麻烦。
Nginx 配置
server {
listen 443 ssl http2;
server_name example.com;
index index.php index.html;
ssl_certificate /path/ssl.crt;
ssl_certificate_key /path/ssl.key;
ssl_dhparam /path/dh.pem;
ssl_buffer_size 8k;
ssl_session_timeout 1d;
ssl_session_cache builtin:1000 shared:SSL:50m;
ssl_session_tickets off;
ssl_trusted_certificate /path/ssl.crt;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 10s;
add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:8080;
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;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header Host $host;
}
}
Apache 配置
<VirtualHost *:8080>
ServerAdmin [email protected]
ServerName example.com
DocumentRoot /var/www/owncloud
<Directory /var/www/owncloud>
Options +FollowSymLinks
Options -Indexes
AllowOverride All
SetEnv HOME /var/www/owncloud
SetEnv HTTP_HOME /var/www/owncloud
SetEnv MOD_X_SENDFILE_ENABLED 1
</Directory>
</VirtualHost>
Owncloud 配置 - /var/www/owncloud/config/config.php
<?php
$CONFIG = array (
'updatechecker' => false,
'instanceid' => 'xxxxxxxx',
'passwordsalt' => 'xxxxxxxx',
'secret' => 'xxxxxxxx',
'overwritehost' => 'example.com:8080',
'overwriteprotocol' => 'https',
'overwritewebroot' => '/',
'proxy' => 'localhost',
'trusted_proxies' => array('192.168.0.2', '127.0.0.1'),
'forwarded_for_headers' => array('HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR'),
'trusted_domains' =>
array (
0 => 'example.com',
),
'datadirectory' => '/not/in/default/data',
'overwrite.cli.url' => 'https://example.com',
'dbtype' => 'mysql',
'version' => '9.0.1.3',
'dbname' => 'dbname',
'dbhost' => 'dbhost',
'dbtableprefix' => 'oc_',
'dbuser' => 'oc_administrator',
'dbpassword' => 'xxxxxx',
'logtimezone' => 'UTC',
'installed' => true,
);
如果我不使用 Nginx,我可以正常访问该网站。但如果我使用 Nginx,页面将加载且没有样式。所有请求都收到 404 响应。
我认为我的 Nginx 代理配置或 Owncloud 配置有问题。我读过这篇文章https://doc.owncloud.org/server/8.0/admin_manual/configuration_server/config_sample_php_parameters.html但我不知道我是否正确地进行了 Owncloud 配置。
多谢你们!
编辑
确实不是造成APACHE 配置或者OWNCLOUD 配置。存在问题JavaScript (.js) 或 CSS (.css) 文件未正确提供-关联。