# HTTP
server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    client_max_body_size 64M;

    # Redirection HTTP -> HTTPS
    #return 301 https://$host$request_uri;

   location / {
      proxy_buffering off;
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Host $server_name;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass http://127.0.0.1:6666;
   }
}

   # Nécessaire pour les redirections internes à Hugo
   location /feed {
       return 302 https://example.com/index.xml;
   }

# HTTPS
server{
   listen 443 ssl http2;
   listen [::]:443 ssl http2;
   
   server_name example.com;
     
   location / {
      proxy_buffering off;
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Host $server_name;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass http://127.0.0.1:6666;
   }

   # Nécessaire pour les redirections internes à Hugo
   location /feed {
       return 302 https://example.com/index.xml;
   }

   #ssl on;
   #ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
   #ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

   access_log /var/log/nginx/hugo_access.log;
   error_log /var/log/nginx/hugo_error.log;
}
