1

我的 Nginx 配置有问题,我们当前的根目录中有 Wordpress,我想通过使用根目录之外的目录在 /owncloud 上设置 owncloud。我试图在 nginx 中设置一个别名,但我不确定来自 nginx 或 php 的“访问被拒绝”。我的 nginx 配置:

server {
    listen   134.34.60.101:80; ## listen for ipv4; this line is default and implied
    # listen   [::]:80 default ipv6only=on; ## listen for ipv6
    listen   134.34.60.101:443 default ssl;
    server_name fachschaft.inf.uni-konstanz.de www.fachschaft.inf.uni-konstanz.de;
    #root /usr/share/nginx/www;
    root /srv/www/website/current;
    index index.php;
    # reroute to old svn for now - Sammy 2013-11-26
    rewrite ^/svn/fachschaft(/.*)$ https://134.34.58.21/svn/fachschaft$1;

    ssl_certificate     ssl/chained-nginx.crt;
    ssl_certificate_key ssl/key-no-pw.pem;
    ssl_session_timeout 5m;
    ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;        
    ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;   
    if ($ssl_protocol = "") {
        rewrite ^ https://www.fachschaft.inf.uni-konstanz.de$request_uri? redirect;
    }
       #Owncloudsettings:
       client_max_body_size 256M; # 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 = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }


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

    }
    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }
    location ~ /adminier {
        # TODO find a better solution...
        alias /srv/www/adminier/index.php;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
    }

        location /owncloud {
        alias /srv/www/owncloud;

        try_files $uri $uri/ /index.php?$args;
#       fastcgi_split_path_info ^(/owncloud/.+\.php)(/.+)$;
        fastcgi_split_path_info ^/owncloud/(.+\.php)(/.+)$;

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

            #Owncloud:
            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;

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

    }



    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    #error_page 500 502 503 504 /50x.html;
    #location = /50x.html {
    #   root /usr/share/nginx/www;
    #}

    # Roots Wordpress Theme Rewrites
    # See http://roots.io/roots-101/
    location ~ ^/assets/(img|js|css|fonts)/(.*)$ {
    try_files $uri $uri/ /content/themes/fsinf-v2/assets/$1/$2;
    }
    location ~ ^/plugins/(.*)$ {
        try_files $uri $uri/ /content/plugins/$1;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
        #fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        # With php5-cgi alone:
        # fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
        #fastcgi_index index.php;
        include fastcgi_params;
    #}

        location ~ ^(.+?\.php)(/.*)?$ {
            try_files $1 = 404;

            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$1;
            fastcgi_param PATH_INFO $2;
            fastcgi_param htaccessWorking true;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
        }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
#   location ~ /\.ht {
#       deny all;

#}

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

有谁知道它将如何工作?

4

1 回答 1

1
于 2014-04-29T22:30:59.080 回答