nginx add_header not working

后端 未结 8 836
无人共我
无人共我 2020-12-23 16:00

I am having an intriguing problem where whenever I use add_header in my virtual host configuration on an ubuntu server running nginx with PHP and php-fpm it sim

8条回答
  •  一整个雨季
    2020-12-23 16:48

    What does your nginx error log say?

    Do you know which add_header lines are breaking the configuration? If not, comment them all out then enable them 1 by 1, reloading nginx to see which one(s) is/are the problem. I would begin by commenting out the block:

    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
    add_header PS 1
    

    The problem could be that you're setting headers not supported by the core httpHeaders module. Installing the NginxHttpHeadersMoreModule may be helpful.

    Also, try replacing the two add_header lines int the location ~* \... with the following:

    add_header Pragma '';
    add_header Cache-Control 'public, max-age=31536000'
    

    Is there a reason you have the gzip configuration here and not in your global nginx.conf?

提交回复
热议问题