Welcome! Log In Create A New Profile

Advanced

Re: Homepage cache and cookies

March 25, 2016 06:10PM
Hello John!

I think you can do this better with sessions in NginX.

I've made a script that checks if a client is a bot or not,
by testing if the Google Analytics cookie is here, or not.

If it is, the client can post a comment or login. If not, the
server is giving a fake page.

In my PHP script :
*****************************************************
$host = $_SERVER['REMOTE_ADDR'];
$session_id = session_id();
$session_name = session_name();
[…]
if ( '' == $session_name ) {
$session_name = '0';
session_start();
echo '<html><head></head><body><h1>server busy, come back later!</h1></body></html>';
exit();
}
[…]
*****************************************************
All pages are cached ;-)

Regards,

Ph. Gras
Le 25 mars 2016 à 22:33, john_smith77 <nginx-forum@forum.nginx.org> a écrit :

> So I found a solution and it seems like there is unexpected behavior from
> nginx. proxy_hide_header Set-Cookie does not seem to work when the location
> block is set to /
>
> So:
>
> location / {
> #Lots of other proxy stuff here......
> proxy_hide_header "Set-Cookie"; }
>
> does not allow a cookie to ever be set, but:
>
> location ~home.html {
> #Lots of other proxy stuff here......
> proxy_hide_header "Set-Cookie"; }
>
> will allow cache HITS but won't cache Set-Cookie headers. Clients are still
> able to get the cookies from the back end and will never get another users
> session cookies.
>
> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,265629,265658#msg-265658
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Homepage cache and cookies

john_smith77 March 24, 2016 09:14AM

Re: Homepage cache and cookies

B.R. March 24, 2016 01:06PM

Re: Homepage cache and cookies

john_smith77 March 24, 2016 04:31PM

Re: Homepage cache and cookies

B.R. March 25, 2016 04:40AM

Re: Homepage cache and cookies

john_smith77 March 25, 2016 09:06AM

Re: Homepage cache and cookies

john_smith77 March 25, 2016 05:33PM

Re: Homepage cache and cookies

ph.gras March 25, 2016 06:10PM

Re: Homepage cache and cookies

B.R. March 26, 2016 06:36AM

Re: Homepage cache and cookies

john_smith77 March 28, 2016 09:51AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 266
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