Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
centminmod /usr/local/nginx/conf/staticfiles.conf non-capture mark regex switch

instructions

switch to non-capturing mark regex for /usr/local/nginx/conf/staticfiles.conf

# backup
cp -a /usr/local/nginx/conf/staticfiles.conf /usr/local/nginx/conf/staticfiles.conf-b4-noncapture-mark
# check before
grep location /usr/local/nginx/conf/staticfiles.conf | grep '\.('
# check switch
sed -e 's|\.(|\.(?:|g' /usr/local/nginx/conf/staticfiles.conf | grep '\.('
# switch
sed -i 's|\.(|\.(?:|g' /usr/local/nginx/conf/staticfiles.conf
# check nginx config
nginx -t
# restart nginx server
ngxrestart

examples

grep location /usr/local/nginx/conf/staticfiles.conf | grep '\.('

location ~* \.(gif|jpg|jpeg|png|ico)$ {
    location ~* \.(3gp|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|test|bin)$ {
    location ~* \.(js)$ {
    location ~* \.(css)$ {
  #  location ~* \.(html|htm|txt)$ {
    location ~* \.(eot|svg|ttf|woff|woff2)$ {
sed -e 's|\.(|\.(?:|g' /usr/local/nginx/conf/staticfiles.conf | grep '\.('

    location ~* \.(?:gif|jpg|jpeg|png|ico)$ {
    location ~* \.(?:3gp|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|test|bin)$ {
    location ~* \.(?:js)$ {
    location ~* \.(?:css)$ {
  #  location ~* \.(?:html|htm|txt)$ {
    location ~* \.(?:eot|svg|ttf|woff|woff2)$ {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment