Advertisement
clseibold

Nginx Reverse Proxy Config for Two Misfin Servers

Feb 7th, 2024
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stream {
  2.  
  3.     ###
  4.     ### Setup
  5.     ###
  6.  
  7.     # connection-limiting
  8.     limit_conn_zone               $binary_remote_addr zone=addr:10m;
  9.     limit_conn_log_level          warn;
  10.     limit_conn                    addr 1;
  11.  
  12.     # logging
  13.     log_format                    basic '$remote_addr $upstream_addr [$time_local] '
  14.                                   '$protocol $status $bytes_sent $bytes_received '
  15.                                   '$session_time';
  16.     access_log                    syslog:server=unix:/dev/log basic;
  17.     error_log                     stderr info;
  18.     error_log                     /var/log/nginx/error.log warn;
  19.  
  20.     # map SNI -> backend service, passes requests from frontend port 1958 to one of backend servers based on the domain used
  21.     map $ssl_preread_server_name  $name {
  22.         hashnix.club           cipres_server;
  23.         server2.hashnix.club   misfin_server;
  24.     }
  25.  
  26.  
  27.     ###
  28.     ### Frontends
  29.     ###
  30.  
  31.     # Misfin - the public-facing port to use for both servers (via different domains)
  32.     server {
  33.         listen                    1958;
  34.         ssl_preread               on;
  35.         proxy_buffer_size         16k;
  36.  
  37.         # pass requests directly to the corresponding Misfin server
  38.         proxy_pass                $name;
  39.     }
  40.  
  41.  
  42.     ###
  43.     ### Backends
  44.     ###
  45.  
  46.     # Misfin servers - backend-facing ports that the reverse proxy will proxy requests to, ensure misfin servers are bound to the bind addresses and ports below
  47.     upstream cipres_server {
  48.         server                   127.0.0.1:1958; # Localhost Bind Address and port of misfin server
  49.     }
  50.     upstream misfin_server {
  51.         server                   127.0.0.1:1959; # Localhost Bind Address and port of misfin server, on different port from cipres_server
  52.     }
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement