Jump to content

How to set multiple domain names on 1 nginx server ?


Recommended Posts

Hello,
Looking at the article https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
I installed nginx under new ubuntu 18 installation under AWS and I want to make multiple domain names on 1 server. Fot this

For this in AWS hosted zone in Route 53 console  I created “sn.votes.demo.org” domain and I see https://prnt.sc/n1166s with domain names name servers at right.
I suppose I have to use this domain name in my domain options.

My /etc/nginx/sites-available/votes.com  :

upstream votes-backend { # Lets you define a group of servers
   server unix:/var/run/php7.2-fpm.sock;
}

server {
   listen 80;
   listen [::]:80;

   root /var/www/votes.com;
   index index.php;

   server_name  nsn.votes.demo.org  www.nsn.votes.demo.org; // domein created above


   # We keep this block, because it doesn't make sense to pass
   # everything to PHP.
   location / {
      # try_files $uri $uri/ =404;
      try_files $uri $uri/ /index.php index.php;

   }

   location ~ \.php$ {
     fastcgi_split_path_info ^(.+\.php)(/.+)$; # this defines a regular expression to separate the SCRIPT_FILENAME and PATH_INFO for later use
     try_files $uri =404; # OR Set cgi.fix_pathinfo=0 in php.ini (for security)
     fastcgi_pass votes-backend; # OR unix:/var/run/php7.2-fpm.sock OR 127.0.0.1:9000
     fastcgi_index index.php; # appends index.php to a URI ending with a slash
     include fastcgi_params;
   }

}

In /etc/hosts :

127.0.0.1 localhost
127.0.0.2   localhost test.com
ec2-13-NN-NN-NN.us-east-2.compute.amazonaws.com   nsn.votes.demo.org  www.nsn.votes.demo.org
# is it correct ?

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Is it valid format ?
I checked log files : /var/log/nginx/access.log, /var/log/nginx/error.log, /var/log/php7.2-fpm.log
But did not find any errors.

Opening www.nsn.votes.demo.orgin browser I see quite different site untergrund.net opened. I have nothing with it.

and I see ref to this site by console command wirth sinilar ref error:

$ curl www.nsn.votes.demo.org
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://www.untergrund.net">here</a>.</p>
<hr>
<address>Apache/2.2.15 (CentOS) Server at www.nsn.votes.demo.org Port 80</address>
</body></html>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.