nginx + fossil configuration problem
Francis Daly
francis at daoine.org
Tue Nov 20 23:24:38 UTC 2012
On Tue, Nov 20, 2012 at 10:29:04PM +0100, Monthadar Al Jaberi wrote:
Hi there,
This isn't a full answer, but hopefully will point you in the right
direction.
> server {
> listen 80;
> server_name locahost;
That is "locahost", not "localhost". That is the reason that the order
of server{} blocks matters.
> location / {
> proxy_pass http://localhost:8080/;
...
> From my host PC I seem to be able to visit my different fossil
> projects 192.168.0.101/aaa and 192.168.0.101/bbb.
If that much works, then you've got a good start.
> But this seems to be accidental, because if I move this server block
> under the default server blocks it stops working.
Not quite: because you have the same "listen" directive in each block,
whichever is first in the file *is* the default.
(http://nginx.org/en/docs/http/server_names.html probably includes more
than you want to know.)
So: when this is the default server block, your fossil access works;
when it isn't, it doesn't. That is down to how nginx chooses which one
server block to use for this request.
> If I have it above I
> cant seems to access the php location block in the default server
> block that I added, 192.169.0.101/index.php don't work.
One request is handled in one server block (usually chosen by comparing
the Host: header with the server_name value), and then in one location
within that server.
Your configuration either uses too many server blocks, or ones with
incorrect server_names.
> Testing from withing the archlinux running nginx:
> localhost/
> localhost/index.html
> localhost/index.php
Those will all use the one server block that has "server_name localhost"
which, below, says "php goes to php-fpm.sock, all else goes to the
filesystem".
> All of these works. But localhost/aaa don't work.
That will also use that same server block. So it will serve files from
/usr/local/nginx/html/aaa.
> If I run the
> following it works:
>
> lynx localhost:8080/aaa
That will use the fossil service directly, avoiding nginx.
> It seems I am missing some last touch. I want to be able to do
> something like 192.168.0.101/fossil/aaa.
Decide exactly what url hierarchy you want to use to access nginx to
reverse proxy to fossil.
That means: which hostname and which /location prefix or prefixes.
Then in the correct server{} block, add the location{} block with the
proxy_pass stuff that you have that already works.
If you want to use *different* hostnames to access fossil and not-fossil,
then you will need to configure location{} blocks in different server{}
blocks.
If you want to use the *same* hostname to access fossil and not-fossil,
then you will need to configure different location{} blocks in the same
server{} block to tell nginx which urls should go to fossil and which
ones should not.
Briefly: move your (working) "location /" block into the "server_name
localhost" server block, and change it to be (perhaps) "location /aaa".
That might show whether you are moving in the right direction.
Good luck,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list