Skip to content

Secure Bank

mrbusysky edited this page Jun 26, 2022 · 2 revisions

Step 1: You must follow the base guide for setting up the bank

Step 2: You need to also edit You need to add your domain and ip address to server_name

Step 3: Once bank it setup the user will need to use certbot to add a domain How to add certbot https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal

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/Bank/media;
    }

    location /static {
        alias /var/www/Bank/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 bank.keysign.app 45.56.92.194 localhost;
    charset utf-8;
    client_max_body_size 75M;

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

    location /static {
        alias /var/www/Bank/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/Bank/media;
    }

    location /static {
        alias /var/www/Bank/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