Jenia Be Nice Please
Jenia Be Nice Please

Reputation: 2693

nginx configuration. how to give different web sites different names?

i have a pointer from sites-enables/qooxdoo to /var/www/qooxdoo/nginx.conf where i have the following:

server {
    listen   80; ## listen for ipv4; this line is default and implied


    root /var/www/qooxdoo;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;
}

to access that web site i need to do: localhost/ that's it. but how do I give a name to that web site?

Sort of localhost/site1 for example.

Thanks in advance for your help jenia ivlev

Upvotes: 0

Views: 680

Answers (1)

Fleshgrinder
Fleshgrinder

Reputation: 16253

Depends on what you exactly want to achieve. Considering the following directories in your filesystem.

/var/www
  - site-1
  - site-2
  - ...
  - site-n

Now you can work with simple directories in the URL if you configure nginx like you've done.

server {
    listen 80;
    root /var/www;
    index index.html index.htm;
    server_name localhost;
}

Requesting http://localhost/site-1 will return the content of the file /var/www/site-1/index.html (and the same for site-2 up to site-n).

If you want to use sub domains you can do the following.

server {
    listen 80;
    root /var/www/site-1;
    index index.html index.htm;
    server_name site-1.localhost;
}

server {
    listen 80;
    root /var/www/site-2;
    index index.html index.htm;
    server_name site-2.localhost;
}

server {
    listen 80;
    root /var/www/site-n;
    index index.html index.htm;
    server_name site-n.localhost;
}

Requesting http://site-1.localhost/ will return the content of the file /var/www/site-1/index.html (and the same for site-2 up to site-n).

Upvotes: 1

Related Questions