2014-02-08 3 views
3

내 nginx 서버의 하위 폴더에 owncloud 인스턴스를 갖고 싶습니다. 하지만 opwncloud에서 요청한 일부 파일에 문제가 있습니다 (CSS 및 js가로드되지 않는 것 같습니다).nginx 및 owncloud 하위 폴더

다음은이 가상 호스트에 대한 nginx를 conf의 파일입니다 :

server { 
    listen   80; 
    server_name blackblock.22decembre.eu; 
    return 301  https://blackblock.22decembre.eu$request_uri; 
} 

server { 
listen 443 default_server ssl; 

server_name blackblock.22decembre.eu; 
root /srv/www/blackblock/; 

access_log /var/log/nginx/blackblock.access.log; 
error_log /var/log/nginx/blackblock.errors.log; 

index index.html index.php; 

# This block will catch static file requests, such as images, css, js 
# The : prefix is a "non-capturing" mark, meaning we do not require 
# the pattern to be captured into $1 which should help improve performance 
location ~* \.(:ico|css|js|gif|jpeg|png)$ { 
    # Some basic cache-control for static files to be sent to the browser 
    expires max; 
    add_header Pragma public; 
    add_header Cache-Control "public, must-revalidate, proxy-revalidate"; 
} 

# remove the robots line if you want to use wordpress" virtual robots.txt 
# location = /robots.txt { access_log off; log_not_found off; } 
location = /favicon.ico { access_log off; log_not_found off; } 

# this prevents hidden files (beginning with a period) from being served 
location ~ /\. { access_log off; log_not_found off; deny all; } 

#location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ { 
location ~ \.php { 
    fastcgi_param SCRIPT_NAME $fastcgi_script_name; 
    #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    fastcgi_param PATH_INFO $path_info; 
    fastcgi_index index.php; 
    fastcgi_pass unix:/run/php5-fpm.sock; 
    include fastcgi_params; 
} 

location /roundcube/program/js/tiny_mce/ { alias /usr/share/tinymce/www/; } 
location /roundcube/(config|temp|logs) { deny all;} 

##### owncloud 
location ~ /owncloud/ { 
root /srv/www/blackblock/owncloud/; 
try_files $uri $uri/ index.php; 

#client_max_body_size 10G; # set max upload size 
    #fastcgi_buffers 64 4K; 

    rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; 
    rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; 
    rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; 

    location ~ ^/remote.php(/.*)$ { 
      fastcgi_split_path_info ^(.+\.php)(/.*)$; 
      fastcgi_pass unix:/run/php5-fpm.sock; 
    include fastcgi_params; 
    } 

    error_page 403 /core/templates/403.php; 
    error_page 404 /core/templates/404.php; 

    location ~ ^/(data|config|\.ht|db_structure\.xml|README) { 
      deny all; 
    } 

# The following 2 rules are only needed with webfinger 
rewrite ^/.well-known/host-meta /public.php?service=host-meta last; 
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; 
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; 
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; 
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; 

    # Optional: set long EXPIRES header on static assets 
    #location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { 
    #  expires 30d; 
      # Optional: Don't log access to assets 
     #  access_log off; 
# } 
} 

    ##### torrent (not related to owncloud, flask application) 
location = /flask-torrent { rewrite^/flask-torrent/ last; } 

} 

내가 찾을 수 owncloud가 제대로로드되지 않는 이유! 당신은 웹 사이트를 볼 수 있습니다, 나는 기분이 좋다 : https://blackblock.22decembre.eu/owncloud/ (cacert 인증서). owncloud에 대한 특정 가상 호스트를 시작하면 완벽하게 작동하지만 원하지 않습니다.이 호스트 (블랙 블록)의 하위 폴더에서 선호합니다!

답변

0

당신이 이미 이것을 검토했지만 게시 한 설정에없는 여러 Nginx 위치 지시문을 포함하여 몇 가지 항목이 있습니다. 구성 참고 사항 (이 게시물 하단의 링크)을 살펴보고 ownCloud 및 ownCloud 데이터에 대한 Nginx 위치 지정 문이 있는지 확인하는 것이 좋습니다.

확인 Nginx에 PHP 처리기 :

귀하의 Nginx의 구성은, PHP5-FPM에 대한 핸들러를 포함 Nginx에 구성의 상단에있는 서버 지시하기 전에이 작업을 넣어해야합니다

upstream php5-fpm-handler { 
     server unix:/var/run/php5-fpm.sock; 
} 

Nginx 지침을 확인하십시오 :

예 :

location /owncloud { 
    rewrite^https://$http_host$request_uri? permanent; 
    } 

    location ~ ^/owncloud/(data|config|\.ht|db_structure\.xml|README) { 
     deny all; 
    } 

PHP5-FPM 구성을 확인하십시오이다 또한

, (보통 어딘가에 우분투 /etc/php5/fpm/pool.d/www.conf 같은) 당신이 PHP5-FPM 풀 구성을 확인하시기 바랍니다 핸들러와 일치해야하는 TCP 포트가 아닌 소켓에서 수신하도록 설정합니다. 포트 대 PHP5-FPM 소켓에 대한 설정 지시어.

예 소켓 : (업스트림 핸들러에 맞게 주석)

listen = /var/run/php5-fpm.sock 

예 포트 : 아직 수행하지 않은 경우에도

;listen = 127.0.0.1:9000 

이의 ownCloud에서 봐 주시기 바랍니다 Nginx에 대한 구성 참고 사항.

http://doc.owncloud.org/server/5.0/admin_manual/installation/installation_others.html

+0

업스트림, 나는 그것에 대해 몰랐습니다! 나는 시도 할 것이다. php5-fpm, 풀 및 소켓이 잘 설정되어 있고 작동하고 있기 때문에 별도의 가상 호스트에 PHP를 실행하는 두 개의 다른 웹 사이트가 있고 두 개 이상의 다른 PHP 서비스가이 별개의 폴더에서 실행되고 있기 때문에 말할 수 있습니다 정확한 가상 호스트. 감사합니다. – 22decembre

+0

많은 문제가 계속 발생합니다. CSS 또는 js 파일을로드 할 수 없습니다. – 22decembre

0

먼저 저를 지적하자 그 //index.php은 어떤 이유로 index 문이 작동하지 않는, 또는 URI가 다른 블록에 일치하는 것을 의미하고있다 아직 작동하지 않습니다.

는, 당신은 subdirecotry에서 유지할 같은 몇 가지를 수정해야 귀하의 설정이 기본 구성은 루트 디렉토리에 설치 owncloud 위해 만들어진 것으로, 마음을 다시 작성을 많이 필요로 location ^~ /owncloud

에 안전 재 작성 location ~ /owncloud/ 되려면 마음에 $uri/owncloud을 포함 할 것이라고 및 /file.ext

rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; 

필요가 있기 때문에 2 가지를 고정 할 수처럼 그렇게 모든 재 작성의 owncloud 폴더 외부

홉 것

rewrite ^/owncloud/caldav(.*)$ /owncloud/remote.php/caldav$1 redirect; 

가 시작을위한 사람들을보십시오 : 는

  • ^/caldav(.*)$이 발생하지 않습니다 , URI는 항상 외부보고 수정 사항이 같은 것
  • 을 owncloud합니다 ^/owncloud

  • /remote.php/...로 시작됩니다
      어떻게되는지 말해줘.

  • +0

    조금 도움이되었지만 여전히 CSS 또는 js 파일이 없습니다. 지금은 적어도 색인이 잘 작동합니다! – 22decembre

    2

    nginx가있는 하위 폴더에서 ownCloud가 작동하지 않는 이유는 nginx가 기본적으로 매개 변수 SCRIPT_NAME에 하위 폴더를 포함하지 않기 때문입니다. ownCloud가 domain.tld/owncloud/index.php 인 경우 $_SERVER['SCRIPT_NAME']/owncloud/index.php이되지만 nginx는 기본적으로 (include fastcgi_params; 인 경우) index.php으로 설정됩니다. 해결 방법은 동작을 재정의하는 것입니다 : fastcgi_param SCRIPT_NAME /owncloud/$fastcgi_script_name;을 nginx conf 파일의 php-location-block에 추가하십시오.

    내 nginx 구성 파일의 관련 부분은 다음과 같습니다. 나는 그것을 완전히 테스트하지 않았다는 것을주의하십시오; 처음에는 그것이 작동하는 것 같습니다. 내 시스템 : Debian Wheezy 64 비트에서 nginx 1.2.1 및 php 5.4.4. 다른 답변의

    location /owncloud/ { 
          alias /var/www/owncloud/; 
          location ~ ^/owncloud/(data|config|\.ht|db_structure\.xml|README) { 
            deny all; 
          } 
          rewrite ^/owncloud/caldav(.*)$ /owncloud/remote.php/caldav$1 redirect; 
          rewrite ^/owncloud/carddav(.*)$ /owncloud/remote.php/carddav$1 redirect; 
          rewrite ^/owncloud/webdav(.*)$ /owncloud/remote.php/webdav$1 redirect; 
          rewrite ^/owncloud/.well-known/host-meta /owncloud/public.php?service=host-meta last; 
          rewrite ^/owncloud/.well-known/host-meta.json /owncloud/public.php?service=host-meta-json last; 
    
          rewrite ^/owncloud/.well-known/carddav /owncloud/remote.php/carddav/ redirect; 
          rewrite ^/owncloud/.well-known/caldav /owncloud/remote.php/caldav/ redirect; 
    
          rewrite ^/owncloud/apps/([^/]*)/(.*\.(css|php))$ /owncloud/index.php?app=$1&getfile=$2 last; 
          rewrite ^(/owncloud/core/doc/[^\/]+/)$ $1/index.html; 
    
          try_files $uri $uri/ index.php; 
    
          location ~ ^/owncloud/(.+?\.php)/? { # note the question mark here and in the next line! 
            fastcgi_split_path_info ^/owncloud/(.+?\.php)(/?.*)$; 
            set $path_info $fastcgi_path_info; # workaround for bug: try_files resets fastcgi_path_info for some reason. 
            try_files $fastcgi_script_name = 404; 
            include fastcgi_params; 
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
            fastcgi_param PATH_INFO $path_info; 
            fastcgi_param HTTPS on; 
            fastcgi_param SCRIPT_NAME /owncloud/$fastcgi_script_name; # !!! 
            fastcgi_pass unix:/var/run/php5-fpm.sock; 
          } 
        } 
    
    +0

    이것을 시도하면 리디렉션 루프가 발생합니다 ... – jmetz

    3

    아무도 나를 위해 일하지, 내가 마지막으로이 블로그에서 작동하는 솔루션을 가지고 :

    server { 
        listen 80; 
        server_name example.com; 
        # enforce https 
        return 301 https://$server_name$request_uri; 
    } 
    
    server { 
        listen 443 ssl; 
        server_name example.com; 
    
        ssl_certificate /etc/ssl/nginx/cloud.example.com.crt; 
        ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key; 
    
        # Add headers to serve security related headers 
        add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; 
        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; 
    
        # Path to the root of your website (one level above owncloud folder) 
        root /var/www; 
        # set max upload size 
        client_max_body_size 10G; 
        fastcgi_buffers 64 4K; 
    
        # Disable gzip to avoid the removal of the ETag header 
        gzip off; 
    
        # Uncomment if your server is build with the ngx_pagespeed module 
        # This module is currently not supported. 
        #pagespeed off; 
    
        # ownCloud blacklist 
        location ~ ^/owncloud/(?:\.htaccess|data|config|db_structure\.xml|README) { 
         deny all; 
         error_page 403 = /owncloud/core/templates/403.php; 
        } 
    
        index index.php; 
    
        location = /robots.txt { 
         allow all; 
         log_not_found off; 
         access_log off; 
        } 
    
        location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){ 
         deny all; 
        } 
    
        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; 
         rewrite ^/owncloud/.well-known/caldav /remote.php/caldav/ redirect; 
    
         try_files $uri $uri/ index.php; 
        } 
    
        location ~ \.php(?:$|/) { 
         fastcgi_split_path_info ^(.+\.php)(/.+)$; 
         include fastcgi_params; 
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
         fastcgi_param PATH_INFO $fastcgi_path_info; 
         fastcgi_param HTTPS on; 
         fastcgi_pass unix:/var/run/php5-fpm.sock; 
        } 
    
        location/{ 
         root /var/www/html/; 
         index index.html; 
        } 
    
        # Optional: set long EXPIRES header on static assets 
        location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { 
         expires 30d; 
         # Optional: Don't log access to assets 
         access_log off; 
        } 
    } 
    

    나는 문서의 풀을 만든 : 여기 http://www.aelog.org/install-owncloud-in-a-subdirectory-using-nginx/

    를 버전입니다 여기에서 요청하십시오 : https://github.com/owncloud/documentation/pull/1704