45

I have a really basic nginx setup which is failing for some reason;

server {
    listen 80;
    server_name librestock.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/david/StockSearch/stocksearch;
    }

    location / {
        include proxy_params;
        proxy_pass unix:/home/david/StockSearch/stocksearch/stocksearch.sock;
    }
}

according to everything I've read I'm setting the server name correctly. when I replace librestock.com with the ip of the server it works.

error:

$ nginx -t
nginx: [emerg] invalid URL prefix in /etc/nginx/sites-enabled/stocksearch:12
nginx: configuration file /etc/nginx/nginx.conf test failed
davegri
  • 2,206
  • 2
  • 26
  • 45

1 Answers1

58

You need the http:// prefix on your unix: path, as in:

proxy_pass http://unix:/home/david/StockSearch/stocksearch/stocksearch.sock;

See

http://nginx.org/en/docs/http/ngx_http_proxy_module.html

Dobes Vandermeer
  • 8,463
  • 5
  • 43
  • 46
  • How aggravatingly dissimilar to the [example in the docs](https://nginx.org/en/docs/stream/ngx_stream_proxy_module.html). – Adam Barnes Jul 05 '23 at 02:20