Getting 502 Bad gateway
tejas3005 opened this issue · comments
Version
latest
Details & Steps to reproduce
i have setup 2FA in my local development env on ubuntu-20.04 i have nginx as server and i am able to access it on http://localhost:8000/ when i run using php artisan serve but when i run using command php artisan 2fauth:install and access it on http://localhost i am getting 502 bad gateway error i have followed steps for self hosted server, earlier i followed same steps using apache as web server on which everything is running fine and as expected but in nginx i am getting 502 bad gateway error on http://loclhost i tried changing server name to localhost in nginx.conf but still same error also i can't undertsand that in apache web server you given steps to create new virtual host and why not in nginx? please help!!
Expectation
i expect it to run on http://localhost
Error & Logs
No response
Execution environment
No response
Containerization
- Docker
Additional information
![image](https://private-user-images.githubusercontent.com/48887643/344311417-e26ecddc-0997-44a6-9e05-a14af209a406.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4NjQ4NTUsIm5iZiI6MTcyMTg2NDU1NSwicGF0aCI6Ii80ODg4NzY0My8zNDQzMTE0MTctZTI2ZWNkZGMtMDk5Ny00NGE2LTllMDUtYTE0YWYyMDlhNDA2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI0VDIzNDIzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY0MTA2YjE2YjllMWZhNTBlMGQ5NmE2NDgxMTgwMTkxY2I0MDc0YjU1YmUwZjk2ODk4MDcwYzEwNmY1ZDg0MmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0o9Aq0rff5cwdQlckb5AGGgzOy15Kxh3Y8CzjDVFMIw)
Could you tell me what configuration you are running in PHP.
Nginx + PHP-FPM
Nginx Has reverse proxy and (Apache + PHP-FPM)
Nginx Has reverse proxy and (Apache + mod_php)
and please paste config file here.
Thanks.
Nginx + php-fpm, i have already posted the nginx config file.
events {}
http {
include mime.types;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server {
listen 80;
server_name localhost;
root /var/www/2fauth/public;
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
# Handle preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
}
location ~ /\.(?!well-known).* {
deny all;
}
}
}
Please can you give me the output of these commands.
- getfacl /var/run/php/php8.3-fpm.sock
- ls -laF /var/run/php/php8.3-fpm.sock
- tail -n 10 /var/log/nginx/error.log
- curl -vi localhost:80
HI,
I managed to fix all issues we can close this thread now, thanks for your help @kamalmjt :)