Advertisement
Sebi

Nginx HTTPS Reverse Proxy

Jan 13th, 2018
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.11 KB | None | 0 0
  1. upstream server1 {
  2.     server 127.0.0.1:8080;
  3. }
  4.  
  5. server {
  6.     listen 443 ssl;
  7.     ssl_certificate /etc/letsencrypt/live/PATH/fullchain.pem;
  8.     ssl_certificate_key /etc/letsencrypt/live/PATH/privkey.pem;
  9.  
  10.     server_name domain.com;
  11.  
  12.     location / {
  13.         proxy_pass          http://server1;
  14.         proxy_set_header    Host             $host;
  15.         proxy_set_header    X-Real-IP        $remote_addr;
  16.         proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
  17.         proxy_set_header    X-Forwarded-Protocol https;
  18.         proxy_pass_header   Authorization;
  19.         proxy_redirect      off;
  20.         proxy_http_version  1.1;
  21.         proxy_buffering     off;
  22.     }
  23. }
  24.  
  25.  
  26. # HTTPS REDIRECTION
  27. server {
  28.     listen 80 default_server;
  29.     server_name _;
  30.     return 301 https://$host$request_uri;
  31. }
  32.  
  33. # DEFAULT SERVER 404
  34. server {
  35.     listen 443 ssl default_server;
  36.     ssl_certificate /etc/letsencrypt/live/PATH/fullchain.pem;
  37.     ssl_certificate_key /etc/letsencrypt/live/PATH/privkey.pem;
  38.     server_name _;
  39.     add_header Strict-Transport-Security "max-age=0;";
  40.     return 404;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement