How to enable Serve static files directly by nginx by default?

Follow

Comments

3 comments

  • Avatar
    Mehmet Emin Aydın

    Update current host using this command

     

    mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e 'select name from dns_zone ORDER BY name ASC' | awk '{print "plesk bin subscription --update-web-server-settings " $1 " -nginx-serve-static true -nginx-static-extensions \"ac3 avi bmp bz2 css cue dat doc docx dts eot exe flv gif gz htm html ico img iso jpeg jpg js mkv mp3 mp4 mpeg mpg ogg pdf png ppt pptx qt rar rm svg swf tar tgz ttf txt wav woff woff2 xls xlsx zip\" "  }' | sh
    0
    Comment actions Permalink
  • Avatar
    Mehmet Emin Aydın

    You can use the following code to add event without logging in to Plesk panel

    plesk bin event_handler --create -command "bash /usr/local/psa/bin/trigger.sh" -priority 0 -user root -event domain_create 
    plesk bin event_handler --create -command "bash /usr/local/psa/bin/trigger.sh" -priority 0 -user root -event subdomain_create


    whole command list
    cat << 'EOF' >> /usr/local/psa/bin/trigger.sh
    #!/bin/bash
    sleep 10
    date >> /tmp/log 2>&1
    echo $NEW_DOMAIN_NAME >> /tmp/log 2>&1
    plesk bin subscription --update-web-server-settings $NEW_DOMAIN_NAME -nginx-serve-static true -nginx-static-extensions "ac3 avi bmp bz2 css cue dat doc docx dts eot exe flv gif gz htm html ico img iso jpeg jpg js mkv mp3 mp4 mpeg mpg ogg pdf png ppt pptx qt rar rm svg swf tar tgz ttf txt wav woff woff2 xls xlsx zip" >> /tmp/log 2>&1

    EOF

    plesk bin event_handler --create -command "bash /usr/local/psa/bin/trigger.sh" -priority 0 -user root -event domain_create
    plesk bin event_handler --create -command "bash /usr/local/psa/bin/trigger.sh" -priority 0 -user root -event subdomain_create
     
    0
    Comment actions Permalink
  • Avatar
    Daria Gavrilova

    Hello @Mehmet,

    Thank you for your input!

    As for the update of web server settings for all domains:
    Usually Serve static files directly by nginx can be enabled for all domains with the following command:
    # plesk bin site -l | while read i; do plesk bin domain --update-web-server-settings $i -nginx-serve-static true; done

    More information on this matter you can also find in the following article: How to update web server settings for all domains via CLI

    As for the creation of Event Handlers via CLI:
    The article was modified accordingly.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request