Home  >  Article  >  Backend Development  >  nginx - php artisan serve runs at 8000 and accesses 502 error

nginx - php artisan serve runs at 8000 and accesses 502 error

WBOY
WBOYOriginal
2016-10-10 11:56:241886browse

Run php artisan serve in the virtual machine (192.168.73.130)
Laravel development server started on http://localhost:8000/
Visit http://192.168.73.130:8000
Result: ERR_CONNECTION_REFUSED

So configure a forwarding in the virtual machine nginx:

<code>server {
                listen 0.0.0.0:80;
                server_name lara.com;

        location / {
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header X-Real-IP $remote_addr;

                proxy_pass http://localhost:8000;
                #proxy_buffering off;
                proxy_redirect on;
                }
        }
</code>

When accessing lara.com in the local browser, it shows 502 Bad Gateway
If you go to curl http://localhost:8000/ in the shell, there will be HTML returned
Is my nginx configuration wrong?
Please solve (Laravel’s environment is very troublesome) ! ! )

Reply content:

Run php artisan serve in the virtual machine (192.168.73.130)
Laravel development server started on http://localhost:8000/
Visit http://192.168.73.130:8000
Result: ERR_CONNECTION_REFUSED

So configure a forwarding in the virtual machine nginx:

<code>server {
                listen 0.0.0.0:80;
                server_name lara.com;

        location / {
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header X-Real-IP $remote_addr;

                proxy_pass http://localhost:8000;
                #proxy_buffering off;
                proxy_redirect on;
                }
        }
</code>

When accessing lara.com in the local browser, it shows 502 Bad Gateway
If you go to curl http://localhost:8000/ in the shell, there will be HTML returned
Is my nginx configuration wrong?
Please solve (Laravel’s environment is very troublesome) ! ! )

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn