You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.9 KiB

  1. reverse-proxy
  2. =============
  3. LILiK's reverse proxy without SSL termination.
  4. Usint nginx with the options `--with-stream` and `--with-stream-ssl_preread` we are able to be a reverse proxy without being a SSL termination.
  5. This configuration enable us to keep SSL certificates on the hosts, not on the router.
  6. Every incoming HTTPS(S) connection must be
  7. - upgraded to HTTPS
  8. - mapped to an `upstream` pool using SNI
  9. - streamed to the designated host
  10. To achieve this with a little modularity we split this configuration
  11. in different directories
  12. nginx.conf
  13. ----------
  14. Using the `stream` directive and SNI variables we can proxy without
  15. terminating the SSL connection.
  16. ```nginx
  17. ```
  18. http.conf.d
  19. -----------
  20. Incoming HTTP connections will be upgraded to HTTPS using a
  21. HTTP redirect; this snippet will handle both GET and POST requests.
  22. Because we like to have free SSL certificates from Let's Encrypt
  23. we must handle their HTTP authentication scheme.
  24. ```nginx
  25. server {
  26. listen 150.217.18.45:80;
  27. server_name bla.lilik.it www.bla.lilik.it;
  28. # handle Let's Encrypt challenges
  29. location /.well-known/acme-challenge/ {
  30. proxy_set_header X-Real-IP $remote_addr;
  31. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  32. proxy_set_header Host $host;
  33. proxy_set_header X-NginX-Proxy true;
  34. # proxy this connection to the host internal ip
  35. # 10.150.42.40
  36. proxy_pass http://10.150.42.40;
  37. }
  38. # redirect correctly both GET and POST requests
  39. location / {
  40. if ($request_method = POST) {
  41. return 307 https://$server_name$request_uri;
  42. }
  43. return 301 https://$server_name$request_uri;
  44. }
  45. }
  46. ```
  47. map.conf.d
  48. -----------
  49. This will map the domains to the upstream
  50. ```nginx
  51. # domain_name upstream_name;
  52. bla.lilik.ti bla_https;
  53. www.bla.lilik.it bla_https;
  54. ```
  55. upstream.conf.d
  56. ---------------
  57. ```nginx
  58. stream bla_https {
  59. server 10.150.42.40:443;
  60. }
  61. ```