Webinoly is just the perfect tool for NGINX experts. Give it a try!
+2 votes
1.1k views
by

how to add below code to nginx?

location ~ .(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
add_header Access-Control-Allow-Origin "*";

2 Answers

0 votes
by Expert

Hi,

Please, read the documentation before asking.

At the end of the site command docs you will find the NGINX setup per site section. Also you can read : https://webinoly.com/support/313/nginx-configuration-for-woocommerce

Are you sure you need to add that header? Webinoly already does it.

Regards.

by
oh, i'm sorry because don't read documentation. I will follow this tutorial. thank you
+2 votes
by Rookie

Just create fonts-nginx.conf file in /var/www/yoursite.com/ directory and add this piece of code. Webinoly adds Access-Control-Allow-Origin for all the extensions except .woff2. It works perfectly for my setup.

location ~* \.(woff2)$ {
   include common/headers-http.conf;
   include common/headers-https.conf;
   add_header "Access-Control-Allow-Origin" "*";
   access_log off;
   log_not_found off;
   expires max;
}
by Rookie
When I create a file to add rules to nginx, such as custom-nginx.conf it seems that the default webinoly configuration file is no longer considered, that is, nginx only considers my custom file. I would like to add just a few additional rules not to replace all

Does that happen to you?
by Rookie
For me adding custom-nginx.conf is working perfectly fine. Default webionly configurations are considered as well
Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

To report a bug, please create a new issue on GitHub or ask a question here with the bug tag.
Webinoly Support Paypal Donations

PayPal · GitHub Sponsors · Bitcoin

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.

...