nginx + fossil configuration problem

Monthadar Al Jaberi monthadar at
Wed Nov 21 18:16:41 UTC 2012

Thank you for your explanations!

The "locahost" error is from my side, I was testing different things
and didn't notice. Sorry.

Okej now I understand, I guess I want one server block, no sense in
having fossil.localhost.

So I want localhost/fossil/aaa.

I moved the working location block inside the default server block:

server {
        listen       80;
        server_name  localhost;
	location /fossil/ {
            proxy_pass http://localhost:8080/;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
	location ~ \.php$ {
	    fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
	    fastcgi_index index.php;
	    root          /usr/share/nginx/html;
	    include       fastcgi.conf;

Now all my other cases work except the fossil one.

When I browse to localhost/fossil/aaa I see that the link changes to:


An extra '/' is added somehow. The page I get is from nginx 404, which
I suppose means nginx did not proxy the request??

best regards,

On Wed, Nov 21, 2012 at 12:24 AM, Francis Daly <francis at> wrote:
> 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 and
> 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.
> ( 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, 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
> 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
> _______________________________________________
> nginx mailing list
> nginx at

Monthadar Al Jaberi

More information about the nginx mailing list