Skip to content

NGINX Setup

NGINX is a common tool for load balancing and reverse-proxying. We will use NGINX to pass your instance to your domains and add SSL to your site.

Assuming you are running a Linux system based off of Debian, run the following command to install NGINX:

sudo apt install nginx

After installing NGINX, configure it in /etc/nginx/nginx.conf. The configuration I would recommend can be found below:

user root; # change this to be the user you are hosting your instance on
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    map_hash_bucket_size 128;

    sendfile on;
    tcp_nopush on;

    tcp_nodelay on;

    reset_timedout_connection on;

    access_log off;
    error_log off;

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name your.domain.com; # replace with your actual domain

        location /wisp {
            proxy_pass http://127.0.0.1:8080; # change this to the port of your wisp server. I recommend an epoxy server for optimal speed and performance.
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            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-Proto $scheme;
        }

        location / {
            proxy_pass http://localhost:8081; # change this to the port of your proxy service
            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-Proto $scheme;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'Upgrade';
            # Increase header buffer
            proxy_connect_timeout 10;
            proxy_send_timeout 90;
            proxy_read_timeout 90;
            proxy_buffer_size 128k;
            proxy_buffers 4 256k;
            proxy_busy_buffers_size 256k;
            proxy_temp_file_write_size 256k;
            # The small block below will block Google search crawlers
            if ($http_user_agent ~ (Googlebot)) {
                return 403;
            }
        }
    }
}