# example of nginx proxy to use with nginx-le - https://github.com/umputun/nginx-le

server {
    listen   443;
    server_name demo.remark42.com;

    ssl    on;
    ssl_certificate         SSL_CERT;
    ssl_certificate_key     SSL_KEY;
    ssl_trusted_certificate SSL_CHAIN_CERT;

    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

    limit_conn perip 10;

    location / {

        #CORS
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, OPTIONS';
        add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With";
        if ($request_method = 'OPTIONS') {
             add_header 'Access-Control-Allow-Origin' '*';
             add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, OPTIONS';
             add_header 'Access-Control-Max-Age'        86400;
             add_header 'Access-Control-Allow-Credentials' 'true';
             add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
             add_header 'Content-Length' 0;
             add_header 'Content-Type' 'text/plain; charset=UTF-8';
             return 204;
         }

         proxy_redirect          off;
         proxy_set_header        X-Real-IP $remote_addr;
         proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header        Host $http_host;
         proxy_pass              http://remark42:8080/;
     }
}
