how can I create a folder to be a sub directory on my domain

May 21, 2014 2.4k views
I installed ghostblog and cannot put another folder on the /var/www to work. eg: www.domain.com/subdirectory to be /var/www/subdirectory
5 Answers
This can be accomplished by add a new location directive to your Nginx server block. Your configuration probably looks something like this:


server {
listen 0.0.0.0:80;
server_name www.domain.com;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;

proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}
}


To direct www.domain.com/subdirectory to /var/www/subdirectory add:


location /subdirectory/ {
alias /var/www/subdirectory/;
}



Let us know how it goes!
I couldn't find the config file, where can I find it?
It's usually in /etc/nginx/sites-enabled.
Thanks for your help guys. I've found the config file, but it didn't work. I think that's something related to the ghostblog config.

Here's the config content.

server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6

root /usr/share/nginx/www;
index index.html index.htm;

# Make site accessible from http://localhost/
server_name www.sergio.filho.org;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}

location /sites/ {
alias /var/www/sites;
try_files $uri $uri/ /index.html;
}

# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}

#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;
#}

# 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;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
@sergiofilhow: On the Ghost blog one-click app, the configuration is located at /etc/nginx/conf.d/default.conf
Have another answer? Share your knowledge.