Bubka / 2FAuth

A Web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes

Home Page:https://docs.2fauth.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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
Screenshot 2024-06-29 020127

Error & Logs

No response

Execution environment

No response

Containerization

  • Docker

Additional information

image ![Screenshot 2024-06-29 020321](https://github.com/Bubka/2FAuth/assets/48887643/881d2f25-c3b1-4dda-b532-2bff5fcf3484) ![Screenshot 2024-06-29 020342](https://github.com/Bubka/2FAuth/assets/48887643/a57520fb-9f79-40e3-b792-1a2714996471)

Screenshot 2024-06-29 020321
Screenshot 2024-06-29 020342

Let me know if you need anything else

commented

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

}
}

commented

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 Managed to fix it now o am able to view login and registration page but i am getting error while registration

Note: i added ssl certificates to access it via https

image

HI,
I managed to fix all issues we can close this thread now, thanks for your help @kamalmjt :)