nginx - Nginx无效的URL前缀

标签 nginx

我有一个非常基本的nginx设置,由于某种原因它失败了;

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

根据我阅读的所有内容,我正在正确设置服务器名称。
当我用服务器的IP替换librestock.com时,它可以工作。

错误:
$ nginx -t
nginx: [emerg] invalid URL prefix in /etc/nginx/sites-enabled/stocksearch:12
nginx: configuration file /etc/nginx/nginx.conf test failed

最佳答案

您需要在unix:路径上使用http://前缀,如下所示:

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

看到

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

关于nginx - Nginx无效的URL前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32992908/

相关文章:

nginx - 在 Nginx 中获取 Http Referer 的主机名

node.js - 尝试从内部羽毛配置socket.io

docker - VM上的Docker NGINX反向代理502错误网关

ubuntu - 如何在 ubuntu nginx 上为 blazor 站点提供正确的 mime 类型

google-chrome - nginx 返回带有 304 响应的 js 的 index.html

php - 如何找到我的 php-fpm.sock?

redirect - nginx 301 重定向到不正确的虚拟主机

asp.net-mvc - ASP MVC主根无法与Mono,fastcgi和nginx一起使用

nginx - 在 nginx 中编辑 header 值

nginx - 通过 kubernetes nginx 连接到 gRPC 服务