使用 Nginx 的前端代理到 locahost 返回 502 bad gateway 错误

使用 Nginx 的前端代理到 locahost 返回 502 bad gateway 错误
vagrant@homestead:~$ ls /etc/nginx
conf.d          koi-win            nginx.conf       sites-enabled  win-utf
fastcgi.conf    mime.types         proxy_params     snippets
fastcgi_params  modules-available  scgi_params      ssl
koi-utf         modules-enabled    sites-available  uwsgi_params

这是我的 sites-enabled/local.lawnhero.com

server {
    listen 80;
    listen 443 ssl http2;
    server_name .local.lawnhero.com;
    root "/home/vagrant/code/lawnhero/public";

    index index.html index.htm index.php;

    charset utf-8;



    location / {
        try_files $uri $uri/ /index.php?$query_string;
        proxy_pass "http://localhost:8000";
    }



    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/local.lawnhero.com-error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }
  ssl_certificate     /etc/nginx/ssl/local.lawnhero.com.crt;
    ssl_certificate_key /etc/nginx/ssl/local.lawnhero.com.key;
}

我正在尝试使用一个名为 Quasar(localhost:8000)的前端 js 框架,并将其与 laravel 5.8 后端(local.lawnhero.com)一起使用

有时 quasar dev 会打开 dev-serverhttp://本地主机:8001

 DONE  Compiled successfully in 7917ms                                                                                                                                                            9:35:27 AM


 N  App dir........... /home/mirage/code/quasar
    App URL........... http://localhost:8001
    Dev mode.......... spa
    Pkg quasar........ v1.1.0
    Pkg @quasar/app... v1.0.6

 app:dev-server Opening default browser at http://localhost:8001 +8s

这是我第一次尝试设置代理,我已经尝试排除故障好几天了。请帮忙哈哈。

网络服务器的错误日志:

2019/09/04 13:50:36 [error] 10716#10716: *38 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.10.1, server: local.lawnhero.com, request: "GET / HTTP/1.1", upstream: "http://[::1]:8000/", host: "local.lawnhero.com"

相关内容