Score:0

Nginx Configuration update issue

ru flag

Previously I was using a domain in my ubuntu VPS server. But currently, I do not want to use the domain in this server. I want to access this server using only IP address in port 80. My server is running on Ubuntu VPS and Nginx. I am very new to Nginx. I can not understand where do I change my configuration file. My Nginx configuration is as follows. Can anyone help me to update my config file?

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

server {

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

    keepalive_timeout 180;
    client_max_body_size 4G;

    proxy_connect_timeout 300s;
    proxy_read_timeout 300s;

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

    location /static/ {
        alias /home/project_folder/static_in_env/static_root/;
    }

    location /media/ {
        alias /home/project_folder/static_in_env/media_root/;
    }

    # 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;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}


server {
    if ($host = www.domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name domain.com www.domain.com;
    return 404; # managed by Certbot
}

Thank you for your valuable time.

Amanullah Aman avatar
ru flag
Currently I do not want to use Domain and SSL
djdomi avatar
za flag
at first why do you comment? Update the question. To use port 80 again you have to use or add port 80 and remove the auto redirect. Moreover you need to replace the domain with either _ for beibg the default or the ip. depending on how many other sites you running on the server
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.