Advertisement
trupsalms

nginx reverse proxy

Apr 29th, 2022
2,737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.46 KB | None | 0 0
  1. user www-data;
  2. worker_processes auto;
  3. pid /run/nginx.pid;
  4. include /etc/nginx/modules-enabled/*.conf;
  5.  
  6. events {
  7.     worker_connections 768;
  8.     # multi_accept on;
  9. }
  10.  
  11. http {
  12.  
  13.     ##
  14.     # Basic Settings
  15.     ##
  16.  
  17.     sendfile on;
  18.     tcp_nopush on;
  19.     tcp_nodelay on;
  20.     keepalive_timeout 65;
  21.     types_hash_max_size 2048;
  22.     # server_tokens off;
  23.  
  24.         # Directives for setting real_ip/XFF IP address in log files
  25.         set_real_ip_from    xxx.xxx.xxx.xxx; #IP address of master LB
  26.         set_real_ip_from    xxx.xxx.xxx.xxx; #IP Address of slave LB
  27.         set_real_ip_from    127.0.0.1; #IP Address of localhost IPV4
  28.         set_real_ip_from    ::1; #IP Address of localhost IPV6
  29.         real_ip_header      X-Forwarded-For;
  30.  
  31.     # server_names_hash_bucket_size 64;
  32.     # server_name_in_redirect off;
  33.  
  34.     include /etc/nginx/mime.types;
  35.     default_type application/octet-stream;
  36.  
  37.     ##
  38.     # SSL Settings
  39.     ##
  40.  
  41.     #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  42.     #ssl_prefer_server_ciphers on;
  43.         # ssl config
  44.         # c.f. https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
  45.         # c.f. https://mozilla.github.io/server-side-tls/ssl-config-generator/
  46.         ssl_session_cache shared:SSL:50m;
  47.         ssl_session_timeout 60m;
  48.  
  49.         # modern
  50.         ssl_protocols TLSv1.2;
  51.         ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
  52.  
  53.         ssl_prefer_server_ciphers on;
  54.         ssl_session_tickets off;
  55.  
  56.  
  57.         # security
  58.         # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
  59.         add_header Strict-Transport-Security max-age=15768000;
  60.  
  61.         # generic proxy settings
  62.         proxy_set_header Host $host;
  63.         proxy_set_header X-Real-IP $remote_addr;
  64.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  65.         proxy_set_header X-Forwarded-Proto $scheme;
  66.  
  67.         # pages may need longer to produce output - this should somewhat correspond to the proxied server timeout
  68.         proxy_read_timeout 400s;
  69.    
  70.  
  71.         ##
  72.     # Logging Settings
  73.     ##
  74.  
  75.         log_format  main  '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
  76.                           '$status $body_bytes_sent "$http_referer" '
  77.                           '"$http_user_agent"';
  78.  
  79.     access_log /var/log/nginx/access.log main;
  80.     error_log /var/log/nginx/error.log;
  81.  
  82.     ##
  83.     # Gzip Settings
  84.     ##
  85.  
  86.     gzip on;
  87.  
  88.     # gzip_vary on;
  89.     # gzip_proxied any;
  90.     # gzip_comp_level 6;
  91.     # gzip_buffers 16 8k;
  92.     # gzip_http_version 1.1;
  93.     # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  94.  
  95.     ##
  96.     # Virtual Host Configs
  97.     ##
  98.  
  99.     include /etc/nginx/conf.d/*.conf;
  100.         #include /etc/nginx/passthrough.conf;
  101.     include /etc/nginx/sites-enabled/*;
  102. }
  103.  
  104.         include /etc/nginx/passthrough.conf;
  105.  
  106. #mail {
  107. #   # See sample authentication script at:
  108. #   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
  109. #
  110. #   # auth_http localhost/auth.php;
  111. #   # pop3_capabilities "TOP" "USER";
  112. #   # imap_capabilities "IMAP4rev1" "UIDPLUS";
  113. #
  114. #   server {
  115. #       listen     localhost:110;
  116. #       protocol   pop3;
  117. #       proxy      on;
  118. #   }
  119. #
  120. #   server {
  121. #       listen     localhost:143;
  122. #       protocol   imap;
  123. #       proxy      on;
  124. #   }
  125. #}
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement