Nginx 服务器配置位置问题

时间:2021-03-07 21:19:58

标签: laravel nginx nginx-location proxypass

我试了又试,似乎遗漏了一些东西。我正在运行 frontail (gituhb) 并希望代理到他们文档中所示的位置,以便 /log-monitor 代理到 127.0.0.1:9001 但是,无论我尝试了什么,我似乎无法从我的主要 Laravel 应用程序中获得重写规则并提供 404。

根据一些建议,我已经尝试过:

  • 向位置块添加 =
  • 添加尾部斜杠 (/log-monitor/)
  • 删除 -monitor 并尝试从 /logs 提供服务,以防连字符导致问题
  • 在下面的代码中移动位置块(上下)

任何帮助将不胜感激。这是我的整个 nginx conf,其中包含从 80 到 443 的 certbot 托管重定向。

    server {
    server_name ************.com;

    access_log /var/log/nginx/util-access.log;
    error_log /var/log/nginx/util-error.log;

    root /var/www/util/public;
    index index.php index.html;


    # serve static files directly
        location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
                access_log off;
                expires max;
                log_not_found off;
        }

        # removes trailing slashes (prevents SEO duplicate content issues)
        if (!-d $request_filename)
        {
                rewrite ^/(.+)/$ /$1 permanent;
        }



        # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
        if (!-e $request_filename)
        {
                rewrite ^/(.*)$ /index.php?/$1 last;
                break;
        }

        location /log-monitor {
            proxy_pass http://127.0.0.1:9001/frontail;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }


        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~* \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
                deny all;
    }



    listen 443 ssl; # managed by Certbot
    ssl_certificate ******; # managed by Certbot
    ssl_certificate_key *********; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = *********.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name **********.com;
    return 404; # managed by Certbot


}

0 个答案:

没有答案