I am unable to specify which names a host should bind to. No matter
what, the routes are matching for localhost. Here's a sample config:
---
handler = Handler(
send_spec='ipc://127.0.0.1:9999',
send_ident='269BC083-7F11-44D2-A10F-3FEA687D0B0F',
recv_spec='ipc://127.0.0.1:9998',
recv_ident='')
static_dir = Dir(
base='static/',
index_file='index.html',
default_ctype='text/plain')
host = Host(
name="foo.mydomain.com",
routes={
'/static/': static_dir,
'/': handler})
server = Server(
uuid="71C307ED-FF01-442B-9ED1-F448C4F8C772",
access_log="/log/mongrel2.access.log",
error_log="/log/mongrel2.error.log",
chroot="./",
default_host="foo.mydomain.com",
name="test",
pid_file="/run/mongrel2.pid",
port=80,
hosts = [host]
)
settings = {"zeromq.threads": 1}
servers = [server]
---
Curling as follows:
curl -I localhost/static
still happily delivers a 404, when it should (I imagine) simply not
handle the request.
HTTP/1.1 404 Not Found
Content-Type: text/plain
Connection: close
Content-Length: 9
Server: Mongrel2/1.7.5
Thanks,
-John
Hello, default_host="foo.mydomain.com", it will default to this host if no other match. loïc On 2012-02-01 18:21, John Krauss wrote: > I am unable to specify which names a host should bind to. No matter > what, the routes are matching for localhost. Here's a sample config: > > --- > > handler = Handler( > send_spec='ipc://127.0.0.1:9999', > send_ident='269BC083-7F11-44D2-A10F-3FEA687D0B0F', > recv_spec='ipc://127.0.0.1:9998', > recv_ident='') > > static_dir = Dir( > base='static/', > index_file='index.html', > default_ctype='text/plain') > > host = Host( > name="foo.mydomain.com", > routes={ > '/static/': static_dir, > '/': handler}) > > server = Server( > uuid="71C307ED-FF01-442B-9ED1-F448C4F8C772", > access_log="/log/mongrel2.access.log", > error_log="/log/mongrel2.error.log", > chroot="./", > default_host="foo.mydomain.com", > name="test", > pid_file="/run/mongrel2.pid", > port=80, > hosts = [host] > ) > > settings = {"zeromq.threads": 1} > > servers = [server] > > --- > > Curling as follows: > > curl -I localhost/static > > still happily delivers a 404, when it should (I imagine) simply not > handle the request. > > HTTP/1.1 404 Not Found > Content-Type: text/plain > Connection: close > Content-Length: 9 > Server: Mongrel2/1.7.5 > > Thanks, > -John -- Dr Loïc d'Anterroches Founder Céondo Ltd w: www.ceondo.com | e: loic@ceondo.com t: +44 (0)207 183 0016 | f: +44 (0)207 183 0124 Céondo Ltd Dalton House 60 Windsor Avenue London SW19 2RR / United Kingdom
Here is a slightly modified config I might use. One domain simply serves
static files and one uses a handler.
###
### Brubeck.io
###
brubeckio_media = Dir(base='brubeck.io/',
index_file='index.html',
default_ctype='text/plain')
brubeckio_host = Host(name="brubeck.io",
routes={'/': brubeckio_media})
###
### Diff_Project
###
diff_project_handler = Handler(send_spec='ipc://diff_project_send',
send_ident='weeeeeee-weee-weee-weee-weeeeeeeeeee',
recv_spec='ipc://diff_project_recv',
recv_ident='')
diff_project_media = Dir(base='diff_project/media/',
index_file='index.html',
default_ctype='text/plain')
diff_project_host = Host(name="diff_project.j2labs.net",
routes={'/media/': diff_project_media,
'/': diff_project_handler})
###
### Server instance
###
the_server = Server(default_host="brubeck.io",
name="the_server",
port=80,
uuid="f400bf85-4538-4f7a-8908-67e313d515c2",
uuid="badddger-bdgr-bdgr-bdgr-snaaaaaaaake",
chroot="./",
access_log="/log/m2.access.log",
error_log="/log/m2.error.log",
pid_file="/run/m2.pid",
hosts=[brubeckio_host, diff_project_host])
###
### Mongrel2 config
###
settings = {"zeromq.threads": 1}
On Wed, Feb 1, 2012 at 12:31 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Hello,
>
> default_host="foo.mydomain.com",
>
> it will default to this host if no other match.
>
> loïc
>
> On 2012-02-01 18:21, John Krauss wrote:
> > I am unable to specify which names a host should bind to. No matter
> > what, the routes are matching for localhost. Here's a sample config:
> >
> > ---
> >
> > handler = Handler(
> > send_spec='ipc://127.0.0.1:9999',
> > send_ident='269BC083-7F11-44D2-A10F-3FEA687D0B0F',
> > recv_spec='ipc://127.0.0.1:9998',
> > recv_ident='')
> >
> > static_dir = Dir(
> > base='static/',
> > index_file='index.html',
> > default_ctype='text/plain')
> >
> > host = Host(
> > name="foo.mydomain.com",
> > routes={
> > '/static/': static_dir,
> > '/': handler})
> >
> > server = Server(
> > uuid="71C307ED-FF01-442B-9ED1-F448C4F8C772",
> > access_log="/log/mongrel2.access.log",
> > error_log="/log/mongrel2.error.log",
> > chroot="./",
> > default_host="foo.mydomain.com",
> > name="test",
> > pid_file="/run/mongrel2.pid",
> > port=80,
> > hosts = [host]
> > )
> >
> > settings = {"zeromq.threads": 1}
> >
> > servers = [server]
> >
> > ---
> >
> > Curling as follows:
> >
> > curl -I localhost/static
> >
> > still happily delivers a 404, when it should (I imagine) simply not
> > handle the request.
> >
> > HTTP/1.1 404 Not Found
> > Content-Type: text/plain
> > Connection: close
> > Content-Length: 9
> > Server: Mongrel2/1.7.5
> >
> > Thanks,
> > -John
>
> --
> Dr Loïc d'Anterroches
> Founder Céondo Ltd
>
> w: www.ceondo.com | e: loic@ceondo.com
> t: +44 (0)207 183 0016 | f: +44 (0)207 183 0124
>
> Céondo Ltd
> Dalton House
> 60 Windsor Avenue
> London
> SW19 2RR / United Kingdom
>
Got it -- so default_host receives everything that's not handled by an explicit host name. This makes intuitive sense, but I wish the manual (at http://mongrel2.org/static/book-finalch4.html#x6-270003.4.1 ) were a little more explicit that's how it works. I'll try to think of some good verbiage and put in a pull request for that piece of doc -- unless I'm totally wrong, here. Thanks for the quick replies! -John On Wed, Feb 1, 2012 at 12:34 PM, James Dennis <jdennis@gmail.com> wrote: > Here is a slightly modified config I might use. One domain simply serves > static files and one uses a handler. > > ### > ### Brubeck.io > ### > > brubeckio_media = Dir(base='brubeck.io/', > index_file='index.html', > default_ctype='text/plain') > > brubeckio_host = Host(name="brubeck.io", > routes={'/': brubeckio_media}) > > > ### > ### Diff_Project > ### > > diff_project_handler = Handler(send_spec='ipc://diff_project_send', > send_ident='weeeeeee-weee-weee-weee-weeeeeeeeeee', > recv_spec='ipc://diff_project_recv', > recv_ident='') > > diff_project_media = Dir(base='diff_project/media/', > index_file='index.html', > default_ctype='text/plain') > > diff_project_host = Host(name="diff_project.j2labs.net", > routes={'/media/': diff_project_media, > '/': diff_project_handler}) > > > ### > ### Server instance > ### > > the_server = Server(default_host="brubeck.io", > name="the_server", > port=80, > uuid="f400bf85-4538-4f7a-8908-67e313d515c2", > uuid="badddger-bdgr-bdgr-bdgr-snaaaaaaaake", > chroot="./", > > access_log="/log/m2.access.log", > error_log="/log/m2.error.log", > pid_file="/run/m2.pid", > > hosts=[brubeckio_host, diff_project_host]) > > > ### > ### Mongrel2 config > ### > > settings = {"zeromq.threads": 1} > > > > On Wed, Feb 1, 2012 at 12:31 PM, Loic d'Anterroches <loic@ceondo.com> wrote: >> >> Hello, >> >> default_host="foo.mydomain.com", >> >> it will default to this host if no other match. >> >> loïc >> >> On 2012-02-01 18:21, John Krauss wrote: >> > I am unable to specify which names a host should bind to. No matter >> > what, the routes are matching for localhost. Here's a sample config: >> > >> > --- >> > >> > handler = Handler( >> > send_spec='ipc://127.0.0.1:9999', >> > send_ident='269BC083-7F11-44D2-A10F-3FEA687D0B0F', >> > recv_spec='ipc://127.0.0.1:9998', >> > recv_ident='') >> > >> > static_dir = Dir( >> > base='static/', >> > index_file='index.html', >> > default_ctype='text/plain') >> > >> > host = Host( >> > name="foo.mydomain.com", >> > routes={ >> > '/static/': static_dir, >> > '/': handler}) >> > >> > server = Server( >> > uuid="71C307ED-FF01-442B-9ED1-F448C4F8C772", >> > access_log="/log/mongrel2.access.log", >> > error_log="/log/mongrel2.error.log", >> > chroot="./", >> > default_host="foo.mydomain.com", >> > name="test", >> > pid_file="/run/mongrel2.pid", >> > port=80, >> > hosts = [host] >> > ) >> > >> > settings = {"zeromq.threads": 1} >> > >> > servers = [server] >> > >> > --- >> > >> > Curling as follows: >> > >> > curl -I localhost/static >> > >> > still happily delivers a 404, when it should (I imagine) simply not >> > handle the request. >> > >> > HTTP/1.1 404 Not Found >> > Content-Type: text/plain >> > Connection: close >> > Content-Length: 9 >> > Server: Mongrel2/1.7.5 >> > >> > Thanks, >> > -John >> >> -- >> Dr Loïc d'Anterroches >> Founder Céondo Ltd >> >> w: www.ceondo.com | e: loic@ceondo.com >> t: +44 (0)207 183 0016 | f: +44 (0)207 183 0124 >> >> Céondo Ltd >> Dalton House >> 60 Windsor Avenue >> London >> SW19 2RR / United Kingdom > >