Welcome! Log In Create A New Profile

Advanced

Apply "X-Frame-Options SAMEORIGIN" for all pages on website, except one folder

Posted by true 
Apply "X-Frame-Options SAMEORIGIN" for all pages on website, except one folder
July 31, 2012 03:13PM
Hello,

i have two locations defined in my nginx config:

server {

.....

rewrite ^/index\.php/?(.*)$ /$1 permanent;

location /widget/ {
index index.php;
try_files $uri @rewritewidget;
#
}

location / {
add_header X-Frame-Options SAMEORIGIN;
index index.php;
try_files $uri @rewriteapp;
}

location @rewritewidget {
rewrite ^(.*)$ /widget/index.php/$1 last;
}

location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}

the idea is that i have 2 entry points, that are using rewrite module. first entry point - is website ("/"), it should send "X-Frame-Options SAMEORIGIN" header. second - widget - is displaying widgets, that should be accessible with iframe tags.

If i add " X-Frame-Options SAMEORIGIN;" to "server" context - it works for whole website (including widgets). if i add " X-Frame-Options SAMEORIGIN;" to "location /" it doesn't work.

Could you please advice me how i can fix this? What i'm doing wrong?

Thanks in advance!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 121
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready