certsocietegenerale / FIR

Fast Incident Response
GNU General Public License v3.0
1.73k stars 505 forks source link

502 BadGateway Error #188

Closed mahesh557 closed 1 year ago

mahesh557 commented 7 years ago

Hi, I am following instructions on https://github.com/certsocietegenerale/FIR/wiki/Installation-on-a-production-environment. I am getting 502 Bad Gateway Error when attempted to http://localhost/admin

I am using ubuntu 16.04 LTS 64 bit

(env-FIR) uma@uma-virtual-machine:~/FIR/FIR/fir/config$ head production.py
..
ALLOWED_HOSTS = ['FIR.DOMAIN.COM','127.0.0.1','localhost']

(env-FIR) uma@uma-virtual-machine:~/FIR/FIR/fir/config$ cat /etc/systemd/system/fir_uwsgi.service 
[Unit]
Description=uWSGI instance for FIR
After=syslog.target

[Service]
User=nginx
Group=nginx
WorkingDirectory=/home/uma/FIR/FIR/
ExecStart=/usr/bin/uwsgi --socket /home/uma/FIR/FIR/run/fir.sock --chdir /home/uma/FIR/FIR/ --module fir.wsgi
Restart=always
KillSignal=SIGQUIT
Type=Debug
StandardError=syslog
NotifyAccess=All

[Install]

● fir_uwsgi.service - uWSGI instance for FIR
   Loaded: loaded (/etc/systemd/system/fir_uwsgi.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Mar 08 00:20:53 uma-virtual-machine systemd[1]: fir_uwsgi.service: Unit entered failed state.
Mar 08 00:20:53 uma-virtual-machine systemd[1]: fir_uwsgi.service: Failed with result 'exit-code'.
Mar 08 00:20:54 uma-virtual-machine systemd[1]: fir_uwsgi.service: Service hold-off time over, scheduling restart.
Mar 08 00:20:54 uma-virtual-machine systemd[1]: Stopped uWSGI instance for FIR.
Mar 08 00:20:54 uma-virtual-machine systemd[1]: fir_uwsgi.service: Start request repeated too quickly.
Mar 08 00:20:54 uma-virtual-machine systemd[1]: Failed to start uWSGI instance for FIR.
Mar 08 00:21:21 uma-virtual-machine systemd[1]: [/etc/systemd/system/fir_uwsgi.service:12] Failed to parse service type, ignoring: Debug
Mar 08 00:21:21 uma-virtual-machine systemd[1]: [/etc/systemd/system/fir_uwsgi.service:14] Failed to parse notify access specifier, ignoring: All
Mar 08 00:22:07 uma-virtual-machine systemd[1]: [/etc/systemd/system/fir_uwsgi.service:12] Failed to parse service type, ignoring: Debug
Mar 08 00:22:07 uma-virtual-machine systemd[1]: [/etc/systemd/system/fir_uwsgi.service:14] Failed to parse notify access specifier, ignoring: All
mahesh557 commented 7 years ago

Found i don't have /usr/bin/uwsgi However found at another path /usr/local/bin/uwsgi Replaced the same in /etc/systemd/system/fir_uwsgi.service and restarted the service. Yet the Problem Persists. uWSGI not instantiated !!! However when i manually run the ExecStart String, It started running without errors.

uma@uma-virtual-machine:~/FIR/FIR$ sudo service fir_uwsgi status
● fir_uwsgi.service - uWSGI instance for FIR
   Loaded: loaded (/etc/systemd/system/fir_uwsgi.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Mar 08 00:35:54 uma-virtual-machine systemd[1]: Started uWSGI instance for FIR.
Mar 08 00:35:54 uma-virtual-machine systemd[1]: fir_uwsgi.service: Main process exited, code=exited, status=217/USER
Mar 08 00:35:54 uma-virtual-machine systemd[1]: fir_uwsgi.service: Unit entered failed state.
Mar 08 00:35:54 uma-virtual-machine systemd[1]: fir_uwsgi.service: Failed with result 'exit-code'.
Mar 08 00:35:54 uma-virtual-machine systemd[1]: fir_uwsgi.service: Service hold-off time over, scheduling restart.
Mar 08 00:35:54 uma-virtual-machine systemd[1]: Stopped uWSGI instance for FIR.
Mar 08 00:35:54 uma-virtual-machine systemd[1]: fir_uwsgi.service: Start request repeated too quickly.
Mar 08 00:35:54 uma-virtual-machine systemd[1]: Failed to start uWSGI instance for FIR.
Mar 08 00:35:56 uma-virtual-machine systemd[1]: [/etc/systemd/system/fir_uwsgi.service:12] Failed to parse service type, ignoring: Debug
Mar 08 00:35:56 uma-virtual-machine systemd[1]: [/etc/systemd/system/fir_uwsgi.service:14] Failed to parse notify access specifier, ignoring: All
uma@uma-virtual-machine:~/FIR/FIR$ cat /etc/systemd/system/fir_uwsgi.service
[Unit]
Description=uWSGI instance for FIR
After=syslog.target

[Service]
User=nginx
Group=nginx
WorkingDirectory=/home/uma/FIR/FIR/
ExecStart=/usr/local/bin/uwsgi --socket /home/uma/FIR/FIR/run/fir.sock --chdir /home/uma/FIR/FIR/ --module fir.wsgi
Restart=always
KillSignal=SIGQUIT
Type=Debug
StandardError=syslog
NotifyAccess=All

[Install]
WantedBy=multi-user.target

uma@uma-virtual-machine:~/FIR/FIR$ /usr/local/bin/uwsgi --socket /home/uma/FIR/FIR/run/fir.sock --chdir /home/uma/FIR/FIR/ --module fir.wsgi
*** Starting uWSGI 2.0.14 (64bit) on [Wed Mar  8 00:36:37 2017] ***
compiled with version: 5.4.0 20160609 on 07 March 2017 22:50:06
os: Linux-4.8.0-39-generic #42~16.04.1-Ubuntu SMP Mon Feb 20 15:06:07 UTC 2017
nodename: uma-virtual-machine
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/uma/FIR/FIR
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/uma/FIR/FIR/
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 8070
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /home/uma/FIR/FIR/run/fir.sock fd 3
Python version: 2.7.12 (default, Nov 19 2016, 06:48:10)  [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1327940
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1327940 pid: 8807 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 8807, cores: 1)
gaelmuller commented 7 years ago

Sorry about the delay, are you still having this issue ?

If so, could you provide your nginx configuration as well as your nginx error logs ?

ghost commented 7 years ago

Im getting same issue... Tried even changing permissions on folder to open it up and still no joy.

my nginx config:

upstream fir { server unix:///opt/FIR/run/fir.sock; }

server { server_name 10.0.1.91;

    location / {
            uwsgi_pass fir;
            include /opt/FIR/run/uwsgi_params;
    }

    location /static/ {
            alias /opt/FIR/static/;
    }

}

My production.py has ALLOWED HOSTS set to the server same as above. == 10.0.1.91

We are allowed to use IP addresses, correct?

image

Ubuntu 16.04.2LTS, Nginx 1.10.0, uwsgi 2.0.15, python 2.7.12

ghost commented 7 years ago

I think this is the issue / fix. I just dont know how to go about it...

http://stackoverflow.com/questions/41038159/cant-run-uwsgi-ini-file-with-systemd-emperor

Mackousko12 commented 7 years ago

Try replacing the following:-

/usr/bin/uwsgi --socket /home/uma/FIR/FIR/run/fir.sock --chdir /home/uma/FIR/FIR/ --plugins python --module fir.wsgi

Augustin-FL commented 1 year ago

The problem is related to your systemd config. You have

User=nginx
Group=nginx

in your config, but your fame instance is in /home/uma/FIR.

You need to either change the username used by systemd when launching fir...or alternatively, you need to change the location of FIR files. They should be in a location readable by nginx user (eg, /usr/share/nginx/html/, /var/www/html, etc..)

This issue is 6 years old, your problem likely got already resolved in the meantime. I will close it, feel free to re-open it if needed.