-1

I am deploying the django app to digitalocean my ip address is not working after the sudo vim /etc/nginx/sites-available/lok in nginx .I added to the my nginx is as follows

upstream app_server {
    server unix:/home/urban/urban.new/run/gunicorn.sock 
fail_timeout=0;
}

server {
   listen 80;

# add here the ip address of your server
# or a domain pointing to that ip (like example.com or www.example.com)
   server_name 139.59.36.32;

   keepalive_timeout 5;
   client_max_body_size 4G;

   access_log /home/urban/urban.new/logs/nginx-access.log;
   error_log /home/urban/urban.new/logs/nginx-error.log;

   location /static/ {
       alias /home/urban/lok/templates/style/static/;
   }

# checks for static file, if not found proxy to app
   location / {
      try_files $uri @proxy_to_app;
  }

  location @proxy_to_app {
     proxy_set_header X-Forwarded-For . $proxy_add_x_forwarded_for;
     proxy_set_header Host $http_host;
     proxy_redirect off;
      proxy_pass http://app_server;
  }
}

but my ip address is not working.Help me to figure out the problem.

Amresh
  • 3
  • 3

1 Answers1

-1

your NGINX vhost config seems OK but you have to change little parameter config:

also you have to correct in your Vhost following line:

server_name  YOURDOMAIN

if dont have a domain then give as placeholder localhost

listen for specific IP with nginx:

listen 139.59.36.32:80 default_server;

see documentation from nginx for more details: nginx.org/en/docs/http/request_processing.html

next correction is that you have to copy /etc/nginx/sites-available/lok to /etc/nginx/sites-enabled/ or create a symlink then reload nginx:

# ln -s /etc/nginx/sites-available/lok /etc/nginx/sites-enabled
# service nginx reload

Background: by default nginx loads conf files that stored under sites-enabled/* (if you dont change the nginx.conf)

also you have to look if the default config exits (on installation by default) ls /etc/nginx/conf.d/default

if the default config exits then mv it to other place so that your vhost config takes the control for every request on ip.

  • 1
    can you help to do it **but you have to copy /etc/nginx/sites-available/lok to /etc/nginx/sites-enabled/lok.conf reload the nginx with: nginx -s reload** – Amresh Dec 23 '18 at 15:18