Francis Daly
February 05, 2014 07:52PM
On Wed, Feb 05, 2014 at 10:55:19AM -0500, justink101 wrote:

Hi there,

> Gosh that is horrible that I have to copy and paste shared headers in the
> server block, to all location blocks. Is this a conscious decision? This

It's nginx. It makes it straightforward to see what configuration applies
to a specific request.

Copy-paste isn't the only way to create the config file.

> makes maintainability very difficult as i have to do something like:

I confess I don't see how it makes maintainability difficult.

If it matters, could you explain?

(It may not matter, of course.)

You can use the nginx directive "include" to refer to another file, as
you do here; or you could use your macro-processing language of choice
to turn your preferred input format into the desired nginx.conf.

> server {

If you use

include shared_headers.conf;

at server level, then you only need to repeat it in locations where you
want different headers added.

> location ^~ /docs {
> include shared_headers.conf;
>
> auth_basic "Docs";
> auth_basic_user_file /etc/nginx/auth/docs.htpasswd;
> }

So you wouldn't need it there, for example.

> location ^~ /actions {
> include shared_headers.conf;
>
> add_header Access-Control-Allow-Origin https://www.mydomain.com;
> }

But you would need it there.

f
--
Francis Daly francis@daoine.org

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

Are headers set in the server block inherited to all location blocks

justink101 February 05, 2014 01:49AM

Re: Are headers set in the server block inherited to all location blocks

Francis Daly February 05, 2014 08:34AM

Re: Are headers set in the server block inherited to all location blocks

Maxim Dounin February 05, 2014 08:54AM

Re: Are headers set in the server block inherited to all location blocks

Francis Daly February 05, 2014 10:12AM

Re: Are headers set in the server block inherited to all location blocks

Maxim Dounin February 05, 2014 11:44AM

Re: Are headers set in the server block inherited to all location blocks

justink101 February 05, 2014 10:55AM

Re: Are headers set in the server block inherited to all location blocks

itpp2012 February 05, 2014 01:51PM

Re: Are headers set in the server block inherited to all location blocks

Francis Daly February 05, 2014 07:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 118
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready