dreamer
dreamer

Reputation: 901

How to retain the domain name while redirecting to my IP

App is using django, nginx and is hosted on aws.
Bought the domain name - mygrounds.in - from godaddy.

In godaddy,in DNS ZONE FILE page, changed the points to column to my aws IP.

On going to my domain name, it is redirected to my IP.
The redirecting part is right, but the problem is , i want the domain name to be retained while redirecting to my IP

UPDATE :

Here is the project_config file from dir:nginx/sites_enabled/

server {
    listen       80;
    server_name  54.186.220.140;

    # location /static/ {

    #    autoindex on;
        # alias "The static files path on your server machine"
    #    alias /home/seenu/tiger_review/staticfiles/;
    #}

    location / {
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $http_host;
         # bind the gunicorn address
         proxy_pass http://0.0.0.0:8000;
      }
 }


One of my colleague help me setup this config file. So not sure on the contents of the config file

Expected behaviour:

on going to mygrounds.in/printo-app/login i should be able to see my app.

Currently the site is live at 54.186.220.140/print-app/login

Do ask, if more clarity is required.
Thanks in advance

Upvotes: 0

Views: 652

Answers (1)

GwynBleidD
GwynBleidD

Reputation: 20539

All you need to do is to add your domain into server_name entry in your nginx config. All names should be separated by whitespaces, so if you want to preserve your site on that IP address, but add also ability to use it on domain, your server_name line should be:

   server_name  54.186.220.140 mygrounds.in;

If you want to serve your app only on domain, it should be:

   server_name  mygrounds.in;

Upvotes: 1

Related Questions