サーバーから 2 つの仮想ホスト (メイン ホストとサブドメイン ホスト) を提供するように nginx を構成しました。主なホストは Rails アプリで、パッセンジャーと共に提供されます。期待どおりに動作します。
サブドメイン ホストは小さな PHP アプリです。このサブドメインに対してブラウザ リクエストを実行すると、403(禁止)エラーが返されます。また、特定のファイルに対してブラウザー リクエストを実行すると、502 (不正なゲートウェイ) エラーが返されます。
nginx.conf ファイルは次のとおりです。
#user nobody;
worker_processes 3;
events {
worker_connections 19000;
}
worker_rlimit_nofile 20000;
http {
include mime.types;
default_type application/octet-stream;
passenger_root /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.18;
passenger_ruby /usr/local/bin/ruby;
sendfile on;
gzip on;
gzip_http_version 1.1;
gzip_disable "msie6";
gzip_vary on;
gzip_comp_level 9;
gzip_static on;
passenger_max_pool_size 6;
passenger_min_instances 1;
passenger_pool_idle_time 10;
# Rails app
server {
listen 80;
server_name .domain.com;
passenger_enabled on;
root /home/ubuntu/rails_app/public;
location ~ ^/assets/ {
expires max;
add_header Cache-Control public;
#add_header Last-Modified "";
#add_header ETag "";
open_file_cache max=1000 inactive=500s;
open_file_cache_valid 600s;
open_file_cache_errors on;
break;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# PHP app
server {
listen 80;
server_name sub.domain.com;
root /home/ubuntu/rails_app/sendy;
index index.html index.htm index.php;
if (!-d $uri) {
set $rule_0 1$rule_0;
}
if (!-f $uri) {
set $rule_0 2$rule_0;
}
if ($rule_0 = "21") {
rewrite ^/([a-zA-Z0-9-]+)$ /$1.php last;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
#root html;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
#fastcgi_index index.php;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /l {
rewrite ^/l/([a-zA-Z0-9/]+)$ /l.php?i=$1 last;
}
location /t {
rewrite ^/t/([a-zA-Z0-9/]+)$ /t.php?i=$1 last;
}
location /w {
rewrite ^/w/([a-zA-Z0-9/]+)$ /w.php?i=$1 last;
}
location /unsubscribe {
rewrite ^/unsubscribe/(.*)$ /unsubscribe.php?i=$1 last;
}
location /subscribe {
rewrite ^/subscribe/(.*)$ /subscribe.php?i=$1 break;
}
location ~ /\.ht {
deny all;
}
}
}
パーミッションの問題だと思いましたが、それらを 744、755、さらには 777 に変更しても、同じエラーが発生します。
何か案は?