Skip to content

Secure Node

mrbusysky edited this page Jun 26, 2022 · 1 revision

Step 1:

  • You must follow the base guide for setting up the validator

Step 2:

  • You need to also edit
  • You need to add your domain and IP address to server_name

Step 3:

Step 4:

  • After they finish setting up the domain and likely ssl they will need to edit the nginx file.
  • Remove listen 80 default_server; from the top server section if it is still there
  • They will need to remove the bottom server settings that certbot setup and replace it with
server {
 
    server_name yourdomain.com yourip localhost;
    listen 80;
    charset utf-8;
    client_max_body_size 75M;

    location /media {
        alias /var/www/Validator/media;
    }

    location /static {
        alias /var/www/Validator/static;
    }

    # Send all non-media requests to the Django server
    location / {
        proxy_pass http://django;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }


}

Your file should then look like this

upstream django {
    server 127.0.0.1:8001;
}

server {
    server_name yourdomain.com yourip localhost;
    charset utf-8;
    client_max_body_size 75M;

    location /media {
        alias /var/www/Validator/media;
    }

    location /static {
        alias /var/www/Validator/static;
    }

    # Send all non-media requests to the Django server
    location / {
        proxy_pass http://django;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }



    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.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 {
 
    server_name yourdomain.com yourip localhost;
    listen 80;
    charset utf-8;
    client_max_body_size 75M;

    location /media {
        alias /var/www/Validator/media;
    }

    location /static {
        alias /var/www/Validator/static;
    }

    # Send all non-media requests to the Django server
    location / {
        proxy_pass http://django;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }


}
Clone this wiki locally