KpuCko

Nginx stream pass client ip address to backend

Aug 28th, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.31 KB | None | 0 0
  1. root@oogway:~# grep -E -v "^$|^#|#" /usr/local/nginx/nginx.conf
  2. user  nginx;
  3. worker_processes  1;
  4. error_log  /var/log/nginx/error.log;
  5. error_log  /var/log/nginx/error.log  notice;
  6. error_log  /var/log/nginx/error.log  info;
  7. events {
  8.     worker_connections  1024;
  9. }
  10. stream {
  11.     include /usr/local/nginx/stream.conf.d/*.conf;
  12. }
  13. http {
  14.     include       mime.types;
  15.     default_type  application/octet-stream;
  16.     sendfile        on;
  17.     keepalive_timeout  65;
  18. }
  19. root@oogway:~#
  20.  
  21. ##################################################################
  22.  
  23. root@oogway:~# grep -E -v "^$|^#|#" /usr/local/nginx/stream.conf.d/443.conf
  24. map $ssl_preread_server_name $name {
  25.     default original_dest;
  26.     vpn.ma3x.org vpn_https;
  27. }
  28. upstream original_dest {
  29.     server 127.0.0.1:443;
  30. }
  31. upstream vpn_https {
  32.     server 127.0.0.1:8443;
  33. }
  34. log_format stream_routing '$remote_addr [$time_local] '
  35.                           'with SNI name "$ssl_preread_server_name" '
  36.                           'proxying to "$name" '
  37.                           '$protocol $status $bytes_sent $bytes_received '
  38.                           '$session_time';
  39. server {
  40.     listen 9443;
  41.     ssl_preread on;
  42.     proxy_pass $name;
  43.     access_log /var/log/nginx/stream_443.log stream_routing;
  44.     ssl_protocols TLSv1.1 TLSv1.2;
  45. }
  46. root@oogway:~#
Add Comment
Please, Sign In to add comment