We are setting up a nginx web server to allow /suburi access in our rails 3.1 app (such as access URL: http://www.railapp.com/subdomain). The subrui name here is byop. Our rails document root subdir is at /var/www/. The suburi byop is at /var/www/byop. Here is what we did after successful rails deployment:
-
Setup the nginx.conf:
server {
listen 80;
server_name 154.248.209.181;
root /var/www/;
passenger_enabled on;
rails_env production;
passenger_base_uri /byop;
} -
Create symbolic link under /var/www as following:
ln -s /var/www/byop/current/public /var/www/byop
nginx was stop and restarted. However 403 Forbidden page shows up for http://154.248.209.181/byop
We checked the symbolic link under /var/www and there is no link listed (only the byop subdir). Here is the output of ls -li:
ubuntu@ip-10-152-95-60:/var/www$ ls -li
total 4
9296 drwxrwsr-x 4 ubuntu www-data 4096 May 6 03:12 byop
What’s wrong with our setup above? Thanks so much.
The problem we found is with the step 2 to create the symlink. The name of the subdir and the name of symbolic link are the same. After using different symlink name, the problem solved. Here is the working copy:
Then http://154.248.209.181/by brings up the page.