2017-05-14 19 views
1

ホームページと文書を異なる場所で実行しようとしていますが、nginx-configを正しく設定する方法がわかりません。NginxをNextcloud/Website /書類作業と併用する

私の作業ツリーが次のようになります。

の/ var/www /の
| - >ウェブサイト
| - > nextcloud
| - >事務処理

私のホームページが到達可能ですweb.domain.comを通じて、私のNextcloud istはcloud.domain.comで到達可能です。 私は、web.domain.com/notesの下でPaperworkを手に入れたいと思っています。 文書ワークのindex.phpは、サブフォルダ "paperwork/frontend/public"にあります。

これは、(全体のSSLとクラウド一部なし)これを解決するために私attempです:

server{ 
    listen 443 ssl http2; 
    server_name web.domain.com; 
    error_log /var/log/nginx/debug.log debug; 

    root /var/www/website; 
    location/{ 
    index index.php index.html; 
    } 

    location /notes { 
      alias /var/www/paperwork/frontend/public; 
      index index.php index.html index.htm; 
      try_files $uri $uri/index.php; 
    } 

    location ~ /(nextcloud|backups) { 
      deny all; 
      return 403; 
    } 
    location ^~ /nextcloud/ { 
      deny all; 
      return 402; 
    } 
    location ^~ /nextcloud/ { 
      deny all; 
      return 402; 
    } 

    location ~ \.php$ { 
      try_files $uri =404; 
      alias /var/www/paperwork/frontend/public; 
      index index.php index.html index.htm; 

      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME 
      $document_root$fastcgi_script_name; 
      include fastcgi_params; 

    } 
} 

彼は間違ったディレクトリを使用しているので、私は別のソリューション多くのことを試してみたが、私はeather 404を取得し、 /var/www/notes/index.php(またはそれに類似したエラー)が見つからないか、nginxがindex.phpをファイルとしてダウンロードしてくれています。

Thxで事前に!

答えて

0

クリーンなソリューションにネストされたロケーションブロックを使用します。あいまいさを避けるには、^~修飾子に注意してください。詳細については、this documentを参照してください。

試してみてください。

location ^~ /notes { 
    alias /var/www/paperwork/frontend/public; 
    index index.php index.html index.htm; 

    if (!-e $request_filename) { rewrite^/notes/index.php last; } 

    location ~ \.php$ { 
     if (!-f $request_filename) { return 404; } 

     fastcgi_pass unix:/var/run/php5-fpm.sock; 

     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 
    } 
} 

try_filesaliasの使用に関してlong standing bugがあります。 ifの使用については、this cautionを参照してください。

fastcgi_param指示文を使用する前に、fastcgi_paramsを含めると、パラメータが上書きされる可能性があります。

+0

ちょうどそれとその動作を試してみました。あなたはすごいです.XX! –