Score:1

NGINX Cors allow origin not match origin

cn flag

I have a big problem in my website.

Since i moved from Apache webserver to Nginx the ads in my site are not working.

I added these lines in my website config file in nginx:

add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Origin,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, HEAD' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Max-Age' '1728000' always;

I did nginx reload but nothing happened.

i tested with curl -X OPTIONS -i https://xy.hu The answer is:

HTTP/1.1 405 Not Allowed
Server: nginx
Date: Mon, 05 Jul 2021 11:14:07 GMT
Content-Type: text/html
Content-Length: 150
Connection: keep-alive
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-XSS-protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Feature-Policy: autoplay 'none'; camera 'none'
Referrer-Policy: same-origin
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept,Authorization,Origin,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, HEAD
Access-Control-Expose-Headers: Content-Length,Content-Range
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1728000
<html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx</center>
</body>
</html>
djdomi avatar
za flag
What is the Question, the headers has been added, why you not showing the full Server Block? Questions seeking installation, configuration or diagnostic help must include the desired end state, the specific problem or error, sufficient information about the configuration and environment to reproduce it, and attempted solutions. Questions without a clear problem statement are not useful to other readers and are unlikely to get good answers.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.