You are not logged in.

#1 2026-11-24 16:58:43

lenhuppe
Member
From: New Hampshire USA
Registered: 2018-12-10
Posts: 340
Website

SOLVED nginx config question

Trying to set up a package proxy cache using nginx following the wiki page here and getting server errors. The server is named lurch.
I can get darkhttpd to work so I know that the client is set up correctly. When I try to test the server using curl on the client I get the following:

curl --haproxy-protocol http://lurch:8080

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.30.8</center>
</body>
</html>

curl http://lurch:8080

<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.30.8</center>
</body>
</html>

My nginx setup in minimal and the http server is working:

nhginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  65;
    types_hash_max_size     2048;
    types_hash_bucket_size  128;
    server {
        listen       80;
        server_name  localhost;
        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;
        }
    }
    server {
        listen 8080;
        root /var/cache/pacman/pkg;
        server_name archcache;
        try_files $uri $uri/;
    }
}

Am I missing something?

Last edited by lenhuppe (2026-11-24 19:41:59)

Offline

#2 2026-11-24 18:33:16

-thc
Member
Registered: 2017-03-15
Posts: 1,245

Re: SOLVED nginx config question

Try adding the error log in the uppermost context:

error_log /var/log/nginx/error.log;

There should be hints there.

Be advised that the nginx "server_name" directive is not something descriptive but the name in the HTTP request itself.

Last edited by -thc (2026-11-24 18:35:21)

Offline

#3 2026-11-24 18:57:53

lenhuppe
Member
From: New Hampshire USA
Registered: 2018-12-10
Posts: 340
Website

Re: SOLVED nginx config question

-thc wrote:

Try adding the error log in the uppermost context:

error_log /var/log/nginx/error.log;

There should be hints there.

Be advised that the nginx "server_name" directive is not something descriptive but the name in the HTTP request itself.

error.log

2026/11/24 13:54:10 [error] 1307#1307: *1 rewrite or internal redirection cycle while internally redirecting to "////////////", client: 10.0.0.207, server: localhost, request: "GET / HTTP/1.1", host: "lurch:8080"
2026/11/24 14:00:51 [error] 1309#1309: *1 directory index of "/var/cache/pacman/pkg/" is forbidden, client: 10.0.0.207, server: localhost, request: "GET / HTTP/1.1", host: "lurch:8080"

Last edited by lenhuppe (2026-11-24 19:02:43)

Offline

#4 2026-11-24 19:23:43

lenhuppe
Member
From: New Hampshire USA
Registered: 2018-12-10
Posts: 340
Website

Re: SOLVED nginx config question

Edited the server block defining the cache. Changed 'try_files $uri $uri/;' to 'autoindex on;' and that fixed it:

nginx.conf

worker_processes  1;
# error_log /var/log/nginx/error.log;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  65;
    types_hash_max_size     4096;
    types_hash_bucket_size  128;

    server {
        listen       80;
        server_name  localhost;

        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;
        }
    }

    server {
        listen 8080;
        root /var/cache/pacman/pkg;
        server_name localhost;
        autoindex on;
        # try_files $uri $uri/;
    }
}

Last edited by lenhuppe (2026-11-24 19:41:20)

Offline

Board footer

Powered by FluxBB