Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

How do I add Access-Control-Allow-Origin in vestacp? cors

General questions about VestaCP
Post Reply
  • Print view
Advanced search
12 posts
  • 1
  • 2
  • Next
lokali
Posts: 14
Joined: Mon Dec 01, 2014 4:45 am

How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by lokali » Mon Dec 28, 2015 10:08 am

i'm using cdn cloudfront and i have error on browser that my font blocked (Access-Control-Allow-Origin)
please anyone can help me how to fix Access-Control-Allow-Origin in vestacp

i have been trying all methods on google i found but all failed.. what conf should i modify? nginx or apache?
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by skurudo » Mon Dec 28, 2015 10:48 am

nginx or apache?
Nginx - /home/user/conf/web/nginx.conf (snginx.conf if you have some)

Code: Select all

location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
           add_header Access-Control-Allow-Origin "*";
And some usefull URL -> http://enable-cors.org/server_nginx.html
Top

lokali
Posts: 14
Joined: Mon Dec 01, 2014 4:45 am

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by lokali » Mon Dec 28, 2015 12:06 pm

all of them don't work..

i have tried the first one several times before and don't work..

the second gives me 404 error..
Top

lukeseven
Posts: 34
Joined: Mon Sep 14, 2015 2:29 pm

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by lukeseven » Sat Dec 03, 2016 10:37 am

Hi,

I am having exactly the same issue running my VPS with nginx web server/CDN cloudfront. It's diving me crazy because I have already tried most of the suggestions and recommendations I found online but no luck.

Still getting these errors in browsers

Access to Font at 'https://css-files.mydomain.com/wp-conte ... f2?v=4.4.0' from origin 'https://css-files.mydomain.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains the invalid value 'mydomain.com'. Origin 'https://mydomain.com' is therefore not allowed access.

Access to Font at 'https://css-files.mydomain.com/wp-conte ... ff?v=4.4.0' from origin 'https://css-files.mydomain.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains the invalid value 'mydomain.com'. Origin 'https://mydomain.com' is therefore not allowed access.

And some more

I am currently using

Code: Select all

location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
           add_header Access-Control-Allow-Origin "*"; 
                }
in my home/mydomain/conf/web/snginx.conf

Please help. Any suggestion or hint will be much appreciated.

Thank
Top

web-seo-consulting
Posts: 35
Joined: Sat Jun 25, 2016 6:56 pm

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by web-seo-consulting » Sat Apr 01, 2017 6:52 am

same problem here
Top

shanjie
Posts: 37
Joined: Thu Jan 14, 2016 12:02 pm

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by shanjie » Tue Jun 27, 2017 8:55 pm

add

add_header Access-Control-Allow-Origin *;

into /etc/nginx/nginx.conf

restart nginx
invalidate those fonts path
Top

pramathesh
Posts: 12
Joined: Mon May 01, 2017 8:38 am

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by pramathesh » Fri Jul 21, 2017 12:23 pm

Facing the same issue! Anyone found a solution to this?
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by skurudo » Tue Jul 25, 2017 9:05 am

(!)
viewtopic.php?f=10&t=10166#p36700

If this don't fit, then please explain, how you test this CORS issue?
Top

raiden
Posts: 7
Joined: Sun Sep 17, 2017 11:17 am

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by raiden » Sun Sep 17, 2017 5:15 pm

# sudo nano /home/user/conf/web/snginx.conf
Add: add_header Access-Control-Allow-Origin "*";
# sudo service nginx restart
worked for me, also it lack woff2 so you need to add it

Code: Select all

server {
    listen      ip:443;
    server_name cdn.domain.com www.cdn.domain.com;
    location / {
        proxy_pass      https://ip:8443;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf|woff2)$ {
            add_header Access-Control-Allow-Origin "*";
        }
    }
}
Top

youradds
Posts: 130
Joined: Tue Sep 01, 2015 10:16 am

Re: How do I add Access-Control-Allow-Origin in vestacp? cors
  • Quote

Post by youradds » Mon Sep 18, 2017 11:32 am

You shouldn't be editing the nginx.conf file directly!!!! Always edit the templates:
/usr/local/vesta/data/templates/web
Failing to do that, will just cause your changes to get lost the next time you update the account from the CP (and can even cause fatal errors, as the template parser does not recognise the new line you added in)

Cheers

Andy
Top


Post Reply
  • Print view

12 posts
  • 1
  • 2
  • Next

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password