How to define nginx code for per Domain?

Discussion in 'Nginx' started by redscience, Dec 11, 2018.

  1. #1
    my /etc/nginx/nginx.conf code is :

    server {
    .....
    location / {
    root /var/www/public_folder;
    index index.php index.html index.htm;
    }
    .
    .
    .
    } 
    Code (markup):
    ------------------------------------------------------------------------------------------------------------------------------------
    and my created Domain config file is:
    nano /etc/nginx/sites-available/definedname.com

    server {
    
    listen 80 default;
    listen 443 http2 default_server;
    listen [::]:443 http2 default_server;
    
    server_name definedname.com www.definedname.com;
    root /var/www/public_folder/definedname.com/$host;
    
    .....
    } 
    Code (markup):

    ------------------------------------------------------------------------------------------------------------------------------------



    when I want to go to my first page, I see global configuration index.html text, who defined within the global configuration route in /etc/nginx/nginx.conf , this text show in my domain first page

    What is my mistake exactly?
     
    redscience, Dec 11, 2018 IP
  2. hostechsupport

    hostechsupport Well-Known Member

    Messages:
    413
    Likes Received:
    23
    Best Answers:
    7
    Trophy Points:
    138
    #2
    You need to define your document root in nginx.conf file.
     
    hostechsupport, Dec 13, 2018 IP