Hot answers tagged

2

What about using some global map directive like map $server_name $base_domain { ~([^.]*)\.([^.]*)$ $1.$2; } map blocks are defined in http context so you can define it separately from your vhosts in the global nginx config. Update As OP noted, this solution wouldn't work with .co.uk domain. I thought of other examples writing this answer - for ...


1

See this clarification. The ngx_brotli developer mentions that something like brotli_proxied isn't required, as it will compress proxied requests by default. server { ... gzip on; gzip_comp_level 5; gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types *; brotli on; ... } Should be sufficient. If the upstream (Cloudfront, in ...


1

Why don't you just reuse $server_name? This variable is set to the first server_name defined in the server block. Just make sure the first defined name is the one you want (and it probably already is).


1

In general there is absolutely no security benefit to encrypting traffic between services running on the same host. (Localhost traffic can only be intercepted by an attacker that has full access to the server. When they can do that they can already access all data stored on your server directly (from the file system) and won't need to bother with ...


1

This approach should work: location ~ "^/user-content/img/([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})(.*)$" { root /srv/foo/bar/uploads; try_files /$1/$2/$3/$1$2$3$4 =404; autoindex off; access_log off; expires 30d; } In the location line, we capture parts of the filename to four different variables using regular expressions, first ...


1

You can try (not tested) location /user-content/img/ { rewrite "^/user-content/img/(\w{2})(\w{2})(\w{2})(.*)" /$1/$2/$3/$1$2$3$4 break; root /srv/foo/bar/uploads; autoindex off; access_log off; expires 30d; } Update Just give it a test. Can confirm that this approach works too. As OP noted, regex with curly braces should be ...


Only top voted, non community-wiki answers of a minimum length are eligible