Web servers

nginxhttp

Reverse Proxies & Service Meshes

Application Servers

Nginx

Optimise for production

Tuning reference:

K8S ingresses based on nginx. Even out of K8S, the configuration templates can be used as a source of information.

Access-Control-Allow-Origin

add_header directives are inherited from the previous configuration level only when the current level defines none. An if block is a configuration level of its own: as soon as it contains an add_header, requests matching it get only the headers defined inside the block, and any add_header set outside is ignored for those requests. So a header that must apply in both cases has to be repeated inside and outside the if.

location @backend {
    internal;

    if ($request_filename ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|txt|css|js|otf|eot|svg|ttf|woff|woff2|map)$) {
        expires 7d;
        add_header "Cache-Control" "public";
        add_header "Access-Control-Allow-Origin" "*";
        access_log off;
    }

    include rdbp/proxy.conf;

    proxy_pass http://ngxps-backend:3080;
    proxy_pass_header Cache-Control;
}

Related