我对 Ubuntu server 15.04 稀疏的支持和文档感到很苦恼。虽然这对于非 LTS 版本来说是可以预料到的。
我有 Nginx 为 Owncloud 提供服务,调用example.com.conf
sites-available 并符号链接到 sites-enabled。OwnCloud 由与 NGinx 相同的服务器提供服务,并具有经过验证的 SSL 证书。
我面临的问题,也是困扰我好几天的问题是如何设置 NGinx 以继续按原样运行(正常工作)并反向代理在同一域中在 192.168.0.24:4000 上运行的 Node.js 应用程序。我希望两者都在同一个域上提供服务(即example.com
Node.js 应用程序充当 ,/
而 OwnCloud 充当/owncloud
。据我所知,Owncloud 是自己从其config.php
文件中执行此操作的?
<?php
$CONFIG = array (
'instanceid' => '***********',
'passwordsalt' => '***************************',
'secret' => '****************************************',
'trusted_domains' =>
array (
1 => 'example.com',
),
'datadirectory' => '/shared/owncloud/data',
'overwrite.cli.url' => 'https://example.com/owncloud',
......
.conf
我猜测文本的底线覆盖了 /owncloud 的 URL,因为我在中找不到它的提示sites-available/enabled
。
upstream php-handler {
server 127.0.0.1:9000;
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name 192.168.0.23 localhost example.com;
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
server_name 192.168.0.23 localhost example.com;
# Add headers to serve security related headers
add_header Strict-Transport-Security max-age=15768000;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
ssl_certificate /etc/nginx/certs/example.crt;
ssl_certificate_key /etc/nginx/certs/example.key;
# Path to the root of your installation
root /var/www/owncloud;
client_max_body_size 10G; # set max upload size
fastcgi_buffers 64 4K;
# ownCloud blacklist
location ~ ^/owncloud/(?:\.htaccess|data|config|db_structure\.xml|README) {
deny all;
error_page 403 = /owncloud/core/templates/403.php;
}
location / {
proxy_pass http://192.168.0.24:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /owncloud/ {
error_page 403 = /owncloud/core/templates/403.php;
error_page 404 = /owncloud/core/templates/404.php;
rewrite ^/owncloud/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/owncloud/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/owncloud/webdav(.*)$ /remote.php/webdav$1 redirect;
rewrite ^(/owncloud/core/doc[^\/]+/)$ $1/index.html;
# The following rules are only needed with webfinger
rewrite ^/owncloud/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/owncloud/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/owncloud/.well-known/carddav /remote.php/carddav/ redirect;
我尝试了所有能想到的方法来解决这个问题,但找不到在同一个域上提供 OwnCloud 和反向代理的方法。我必须有一个单独的.conf
文件吗?我很困惑。