Re: Using $upstream_response_time in add_header shows a dash

2021-02-07 Thread MarioIshac
; > shows that nginx knows the $upstream_response_time at log time, as I > get > > this log: > > > > 127.0.0.1:8001 200 0.004 > > > > Why does nginx substitute the request time and relevant response > metadata > > (like $upstream_status) at add_hea

Re: Using $upstream_response_time in add_header shows a dash

2021-02-07 Thread Maxim Dounin
me: - > > `cat app.log` shows that upstream was hit successfully, and `cat nginx.log` > shows that nginx knows the $upstream_response_time at log time, as I get > this log: > > 127.0.0.1:8001 200 0.004 > > Why does nginx substitute the request time and relevant response metadata

Using $upstream_response_time in add_header shows a dash

2021-02-05 Thread MarioIshac
log: 127.0.0.1:8001 200 0.004 Why does nginx substitute the request time and relevant response metadata (like $upstream_status) at add_header time successfully, yet substitutes the upstream response time with a dash? My goal with returning $upstream_response_time in a header is so the client ca

Re: add_header

2017-06-21 Thread steve
ems rather strange. Is it supposed to work this way? If your location blocks contain any add_header directives then those comming from server {} block are ignored (and you have to repeat them). rr ___ nginx mailing list nginx@nginx.org http://mailman

Re: add_header

2017-06-21 Thread Reinis Rozitis
The solution was to also add that header to the location{} block that I use to manage the relevant static resources. This seems rather strange. Is it supposed to work this way? If your location blocks contain any add_header directives then those comming from server {} block are ignored (and

add_header

2017-06-21 Thread steve
Hi folks, As a precaution against CORS, I add_header Access-Control-Allow-Origin *; outside any location{} block in my server{} definition. I have recently had a problem where I deliver .css via a CDN, and that CDN references font files also on the CDN, and this was triggering CORS, so

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-10 Thread c0nw0nk
st ~* www(.*)) { > > set $host_without_www $1; > > } > > set_by_lua $expires_time 'return > ngx.cookie_time(ngx.time()+2592000)'; > > add_header Set-Cookie > > "value=1;domain=$host_without_www;path=/;expires=$expires_ > &

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-10 Thread B.R.
with expires and max-age cookie vars. > > if ($host ~* www(.*)) { > set $host_without_www $1; > } > set_by_lua $expires_time 'return ngx.cookie_time(ngx.time()+2592000)'; > add_header Set-Cookie > "value=1;domain=$host_without_www;path=/;expires=$expires_ >

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-10 Thread c0nw0nk
92000)'; add_header Set-Cookie "value=1;domain=$host_without_www;path=/;expires=$expires_time;Max-Age=2592000"; Posted at Nginx Forum: https://forum.nginx.org/read.php?2,269438,269452#msg-269452 ___ nginx mailing list nginx@nginx.org http://mailm

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-09 Thread Robert Paprocki
Actually no, ngx.time() is not expensive, it uses the cached value stored in the request so it doesn't need to make a syscall. > On Sep 9, 2016, at 06:33, itpp2012 wrote: > > Good, keep in mind that "ngx.time()" can be expensive, it would be advisable > to use a global var to store time and upd

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-09 Thread c0nw0nk
Can you provide a example also I seem to have a new issue with my code above it is overwriting all my other set-cookie headers how can i have it set that cookie but not overwrite / remove the others it seems to be a unwanted / unexpected side effect. Posted at Nginx Forum: https://forum.nginx.org

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-09 Thread itpp2012
Good, keep in mind that "ngx.time()" can be expensive, it would be advisable to use a global var to store time and update this var once every hour. Posted at Nginx Forum: https://forum.nginx.org/read.php?2,269438,269444#msg-269444 ___ nginx mailing lis

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-09 Thread c0nw0nk
Solved it now i forgot in lua i declare vars from nginx different. header_filter_by_lua ' ngx.header["Set-Cookie"] = "value=1; path=/; domain=" .. ngx.var.host_without_www .. "; Expires=" .. ngx.cookie_time(ngx.time()+2592000) -- +1 month 30 days '; Posted at Nginx Forum: https://forum.n

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-09 Thread c0nw0nk
if ($host ~* www(.*)) { set $host_without_www $1; } header_filter_by_lua ' ngx.header["Set-Cookie"] = "value=1; path=/; domain=$host_without_www; Expires=" .. ngx.cookie_time(ngx.time()+2592000) -- +1 month 30 days '; So i added this to my config but does not work for me :( Posted at Ngin

Re: add_header Set-Cookie The difference between Max-Age and Expires

2016-09-09 Thread itpp2012
In Lua it's as easy as: https://github.com/openresty/lua-nginx-module/issues/19#issuecomment-19966018 Posted at Nginx Forum: https://forum.nginx.org/read.php?2,269438,269439#msg-269439 ___ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mai

add_header Set-Cookie The difference between Max-Age and Expires

2016-09-09 Thread c0nw0nk
So i read that IE8 and older browsers do not support "Max-Age" inside of set-cookie headers. (but all browsers and modern support expires) add_header Set-Cookie "value=1;Domain=.networkflare.com;Path=/;Max-Age=2592000"; #+1 month 30 days Apprently they support "expires

Re: Nginx overwrite existing cookies with add_header

2016-08-25 Thread c0nw0nk
I sorted out this problem now Here was my soloution. if ($host ~* www(.*)) { set $host_without_www $1; } add_header Set-Cookie "logged_in=1;Domain=$host_without_www;Path=/;Max-Age=31536"; Posted at Nginx Forum: https://forum.nginx.org/read.php?2,269189,269190#

Nginx overwrite existing cookies with add_header

2016-08-25 Thread c0nw0nk
So i am using Nginx to set a header now my PHP app sets this header too but it sets the cookie with a domain of ".networkflare.com" Nginx keeps setting it as "www.networkflare.com" i need to overwrite the cookie not create a new one. I have tried the following : add_header S

Re: Multiple add_header

2015-07-06 Thread Alt
Hello okamzol and thanks a lot for your answer! Yes, it's exactly the same question, looks like I'll need to use include. Best Regards Posted at Nginx Forum: http://forum.nginx.org/read.php?2,260102,260104#msg-260104 ___ nginx mailing list nginx@ngin

Re: Multiple add_header

2015-07-06 Thread okamzol
Hi, there is no chance to avoid the duplicates. I asked the same questions some time ago. For detailed answer on my question see http://forum.nginx.org/read.php?2,256270,256279#msg-256279. I think this will answer your question too. Best Regards Posted at Nginx Forum: http://forum.nginx.org/re

Multiple add_header

2015-07-06 Thread Alt
Hello, I'm using PHP with nginx 1.9.2 and it works great! But there's something I don't understand with the add_header directive. I use add_header in server and location block, but it seems only the one in location is used. If I remove the add_header in the location block, I g

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

2015-02-18 Thread Valentin V. Bartenev
On Wednesday 18 February 2015 17:57:13 Daniël Mostertman wrote: [..] > What am I doing wrong, if anything? And if I can avoid using "if" like > that, I'd obviously prefer that. > You can avoid it by using the map directive and a variable as the add_header v

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

2015-02-18 Thread Daniël Mostertman
Hi again, And ugh, yet again realising what I did wrong right after hitting "send": Daniël Mostertman schreef op 18-2-2015 om 17:57: tl;dr: I want do have an add_header inside an if {}. nginx 1.7.10 won't let me. Because I didn't put the if inside a location. Ac

'add_header' no longer allowed inside 'if', even though document says it is?

2015-02-18 Thread Daniël Mostertman
Hi! I'm currently running 1.7.10 mainline straight from the nginx.org repository. We are hosting an application that needs to be accessible to Internet Explorer users, in addition to all other *normal* browsers. tl;dr: I want do have an add_header inside an if {}. nginx 1.7.10 won'

Re: add_header is not working in certain locations

2014-08-14 Thread Francis Daly
On Thu, Aug 14, 2014 at 10:16:43AM -0400, bodomic wrote: Hi there, > Actually, the second problem is described in this document too, I think I > should re-read it every time I want to use IF. "if" is fine. It is only "if inside location" which needs care. My general guideline is: do "return .

Re: add_header is not working in certain locations

2014-08-14 Thread bodomic
Actually, the second problem is described in this document too, I think I should re-read it every time I want to use IF. In my example (before posting it here) I've dropped the second IF in the same location without much thought. That's why it worked for you. That's why it worked in a separate loca

Re: add_header is not working in certain locations

2014-08-14 Thread bodomic
Thanks for your reply, I've actually found the second traitor (i.e. why second example won't work), will reply to Francis's post once more. Posted at Nginx Forum: http://forum.nginx.org/read.php?2,252523,252574#msg-252574 ___ nginx mailing list nginx@n

Re: add_header is not working in certain locations

2014-08-14 Thread itpp2012
Adding a few notes: IF should only be used to return a state, ea. if ... 'error_page' and nothing else because it breaks the chain of processing, when you really need IF's, nested, setting values or otherwise use Lua. For example: http://forum.nginx.org/read.php?2,251650,251777#msg-251777 The prob

Re: add_header is not working in certain locations

2014-08-14 Thread bodomic
Hi Francis, Thanks for your thoughtful entry. It seems that it is a cloudy area of buggy 'if' behaviors :) I've created empty host config with just 'location /' and 'if ... add_header' and proxy_pass - and it works fine. I'll have to retest this situation

Re: add_header is not working in certain locations

2014-08-13 Thread Francis Daly
On Wed, Aug 13, 2014 at 02:28:27AM -0400, bodomic wrote: Hi there, > Hi all, I've got strange behavior that I don't understand in two different > configs. I'll post examples below, in both of them I use add_header two > times and one of them is not working while sec

add_header is not working in certain locations

2014-08-12 Thread bodomic
Hi all, I've got strange behavior that I don't understand in two different configs. I'll post examples below, in both of them I use add_header two times and one of them is not working while second does. Example 1: Request is: http://hostname/?region=XX #This location adds

Re: Why the status code restriction on add_header?

2013-12-05 Thread Maxim Dounin
Hello! On Thu, Dec 05, 2013 at 11:54:56AM +0100, Richard Stanway wrote: > Hello, > I'm trying to add some custom headers to a 403 response, but had a hard > time doing so. Looking through the docs, it seems add_header "Adds the > specified field to a response header prov

Why the status code restriction on add_header?

2013-12-05 Thread Richard Stanway
Hello, I'm trying to add some custom headers to a 403 response, but had a hard time doing so. Looking through the docs, it seems add_header "Adds the specified field to a response header provided that the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307. " I was

Re: Using add_header at server level context

2013-10-07 Thread Thijs Koerselman
Thanks. So using add_header in the location scope omits any earlier add_header statements used in the parent scope. I am surprised that it works like that, but it's definitely good to know. On Mon, Sep 30, 2013 at 4:30 PM, Francis Daly wrote: > On Mon, Sep 30, 2013 at 03:42:50PM +020

Re: Using add_header at server level context

2013-09-30 Thread Francis Daly
On Mon, Sep 30, 2013 at 03:42:50PM +0200, Thijs Koerselman wrote: Hi there, > From the add_header docs I understand that it works at location, http and > server context. But when I use add_header at the server level I don't see > the headers being added to the response. > Am I

Using add_header at server level context

2013-09-30 Thread Thijs Koerselman
>From the add_header docs I understand that it works at location, http and server context. But when I use add_header at the server level I don't see the headers being added to the response. For example my server config starts with: server { listen9088; ser

Re: understanding break and add_header combo

2013-05-03 Thread flarik
Francis Daly Wrote: --- Hello Francis, thanks for your response. > In nginx, one request is handled in one location. So I expect that no more > than one set of add_header directives will apply. And as you only show > regex location

Re: understanding break and add_header combo

2013-05-02 Thread Francis Daly
On Thu, May 02, 2013 at 11:53:12AM -0400, flarik wrote: Hi there, > location ~ ^/assets/ { > location ~* \.(ttf|ttc|otf|eot|woff)$ { > Now the add_header stuff for webfonts is never set, and I do not understand > why break has a part in this. When I remove break; it works, >

understanding break and add_header combo

2013-05-02 Thread flarik
Hello, I'm trying to undestand the break; statement in combination with add_header combo, on the wiki it says the following: "Completes the current set of rules. Continue processing within the current location block but do not process any more rewrite directives." I read this as