<div dir="auto">Hi,<div dir="auto"><br></div><div dir="auto">I tried using inline script by allowing unsafe-inline in Content Security Policy header but am getting below error.</div><div dir="auto"><br></div><div dir="auto">Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self'. Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.<br></div><div dir="auto"><br></div><div dir="auto">I am able to generate sha256/nonce from code but how to validate and set in response header in Nginx.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 10, 2019, 6:39 AM Sathish Kumar <<a href="mailto:satcse88@gmail.com">satcse88@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Hi,<div dir="auto"><br></div><div dir="auto">I would like to enable Content Security Policy header on Nginx for our website to protect from data injection attacks and XSS. Can I add like the below config?. If anybody hit our URL they will know the allowed domains in the header.</div><div dir="auto"><br></div><div dir="auto">Is there any other bettery way to do this?</div><div dir="auto"><div dir="auto"><br></div></div><div dir="auto"><div dir="auto">add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' <a href="https://ssl.google-analytics.com" target="_blank" rel="noreferrer">https://ssl.google-analytics.com</a> <a href="https://assets.zendesk.com" target="_blank" rel="noreferrer">https://assets.zendesk.com</a> <a href="https://connect.facebook.net" target="_blank" rel="noreferrer">https://connect.facebook.net</a>; img-src 'self' <a href="https://ssl.google-analytics.com" target="_blank" rel="noreferrer">https://ssl.google-analytics.com</a> <a href="https://s-static.ak.facebook.com" target="_blank" rel="noreferrer">https://s-static.ak.facebook.com</a> <a href="https://assets.zendesk.com" target="_blank" rel="noreferrer">https://assets.zendesk.com</a>; style-src 'self' 'unsafe-inline' <a href="https://fonts.googleapis.com" target="_blank" rel="noreferrer">https://fonts.googleapis.com</a> <a href="https://assets.zendesk.com" target="_blank" rel="noreferrer">https://assets.zendesk.com</a>; font-src 'self' <a href="https://themes.googleusercontent.com" target="_blank" rel="noreferrer">https://themes.googleusercontent.com</a>; frame-src <a href="https://assets.zendesk.com" target="_blank" rel="noreferrer">https://assets.zendesk.com</a> <a href="https://www.facebook.com" target="_blank" rel="noreferrer">https://www.facebook.com</a> <a href="https://s-static.ak.facebook.com" target="_blank" rel="noreferrer">https://s-static.ak.facebook.com</a> <a href="https://tautt.zendesk.com" target="_blank" rel="noreferrer">https://tautt.zendesk.com</a>; object-src 'none'";</div><div dir="auto"><br></div><div dir="auto"><br></div></div></div>
</blockquote></div>