Question regarding Nginx Configuration

I have Nginx up and running but I think that the conf file could be
improved upon.

I have a single server hosting 2 domains (doma and domb).

doma is the default virtual host and supports a number of applications
all of which use Perl scripts.

domb has a separate domain name (obviously!) and supports one
application that has a Wordpress/PHP frontend plus a secure Perl
application

All doma static web pages are held in sub-directories under a root of
…/htdocs

The domb ‘static’ Wordpress pages (including all PHP pages) are in
…/htdocs/domb & sub-directories

All Perl scripts for both doma and domb are in …/cgi-bin
sub-directories including …/cgi-bin/domb for the secure domb apps.

As I understand it I have to have 3 server blocks:-

Block 1 - default port 80
Block 2 - domb port 80
Block 3 - domb port 443

Unfortunately it seems that I have to replicate the location …htdocs
and cgi-bin*.pl$ blocks3 times (once for each server block) and the
/*.php$ block twice (for domb 80 and domb 443). This, I think, is
because location blocks can only exist within server blocks.

Is it possible for location blocks to exist within the main http block
at a higher level than the server block (I’ve tried it and it didn’t
work for me but that might have been because I had got some other
configuration statements wrong)?

TIA

Doug

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,216128,216128#msg-216128

Is it possible for location blocks to exist within the main http block at
a higher level than the server block?

No, but if you have a lots of repeating configuration/locations in the
server blocks you can move those to a seperate file and then use include
(
http://wiki.nginx.org/CoreModule#include ) instead.

rr

Yes, I thought of that and it would certainly reduce the amount of
duplication. However I do think that there are times when location
directives apply to the whole server (the real server, that is, not the
virtual host) and it would be nice to be able to use them at the higher
level.

Maybe that is one for the wishlist?

Doug

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,216128,216154#msg-216154

Igor S. Wrote:

Igor S.

I guess that is certainly enough reason not to include them in Nginx -
and thank you for making a very good alternative available, I certainly
couldn’t do any better!

My question, originally, was about whether I had correctly understood
how to construct the conf file; or whether it could be done more
efficiently and I had not understood how to do that.

However, my config works and it was a lot easier than Apache - maybe I
should just count my blessings.

Doug

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,216128,216210#msg-216210

On Sat, Oct 01, 2011 at 08:07:03AM -0400, dougconran wrote:

Yes, I thought of that and it would certainly reduce the amount of
duplication. However I do think that there are times when location
directives apply to the whole server (the real server, that is, not the
virtual host) and it would be nice to be able to use them at the higher
level.

Maybe that is one for the wishlist?

Locations, Directories, and other blocks in the global server
configuration is one of features I never liked in Apache, so
this is reason why they were not implemented in nginx.


Igor S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs