Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtual Directory counterpart in nginx

It seems nginx does not support embeded location bloks. Does this mean there is no VirtualDirectory counterpart in nginx?

What is nginx conf of following Apache conf:

Alias /foo "D:\www\foo\public"
<Directory "D:\www\foo\public">
     # some settings
</Directory>
Alias /bar "D:\www\bar\public"
<Directory "D:\www\bar\public">
     # some other config
</Directory>
like image 260
Handsome Nerd Avatar asked Feb 07 '14 12:02

Handsome Nerd


People also ask

Where is virtual host file nginx?

Virtual host config files are typically located in the /etc/nginx/sites-available directory. You may also notice that your server has a /etc/nginx/sites-enabled folder, which is where file shortcuts (symbolic links) are placed.

What is virtual directory?

A virtual directory is a path or alias within a website that refers users to another directory where the actual data is hosted. The referred directory can be a physical directory on a local server's hard drive or a directory on another server (network share).

What is server block in nginx?

Nginx Server Blocks allows you to run more than one website on a single machine. With Server Blocks, you can specify the site document root (the directory which contains the website files), create a separate security policy for each site, use different SSL certificates for each site, and much more.


1 Answers

It would be:

location /foo/ {
    alias d:/www/foo/public/;
}
location /bar/ {
    alias d:/www/bar/public/;
}

Note that there is a longstanding bug that alias and try_files don't work together.

like image 173
Tan Hong Tat Avatar answered Nov 15 '22 17:11

Tan Hong Tat