Skip to content

Installation Guide: nginx

Mark Hughes edited this page May 13, 2021 · 1 revision

Wiki Home / Installation Guides / nginx


This guide is for how you can setup droppy with nginx, a popular web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. For this use case, we're setting up nginx to work with a reverse proxy.

Configuration

http {
  tcp_nopush on;
  tcp_nodelay on;

  # Upstream group for droppy 
  upstream droppy {
    # If you changed the port of droppy, you can change it here.
    server 127.0.0.1:8989; 
  }

  # Example block, the same logic inside the location applies to any port (include https!) 
  server {
    listen 80;
    listen [::]:80;

    server_name droppy.example.com;

    access_log /var/log/nginx/droppy.example.com.access.log;
    error_log /var/log/nginx/droppy.example.com.error.log;

    location / {
      # Note the end slash here on droppy is really important, do not remove. 
      proxy_pass http://droppy/;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade; # required for ws!
      proxy_set_header Connection $http_connection;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Real-Port $remote_port;
      proxy_http_version 1.1;
      proxy_cache off;
      proxy_buffering off;
      proxy_redirect off;
      proxy_request_buffering off;
      proxy_ignore_client_abort on;
      proxy_connect_timeout 7200;
      proxy_read_timeout 7200;
      proxy_send_timeout 7200;
      client_max_body_size 0;
    }
  }
}

If you would like to put droppy under a different directory, you can change location like so and add the following link inside the block:

    # change "droppy" in the location and rewrite as needed
    location /droppy/ {
      rewrite /droppy/(.*)$ /$1 break;

      proxy_pass http://droppy/; # do not change this one though!
      proxy_set_header Host $host;

      # .. and all the other settings as in the previous example! 
    }
Clone this wiki locally