|
OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD. |
|
Thread Tools | Display Modes |
|
|||
Debugging httpd-gunicorn.sock
Dear Users,
TL,DR; I tried to run my flask app by using Gunicorn and httpd. Socket renders page with "curl -v --unix-socket /var/www/run/gunicorn.sock http://localhost/" but when you hit the server you got 500 error. httpd.conf: Code:
prefork 3 server "www.example.com" { listen on * port 80 location "/*" { fastcgi socket "/var/www/run/gunicorn.sock" root "cython_test" } } types { include "/usr/share/misc/mime.types" } -I checked the httpd logs and it says: Code:
server www.example.com, client 1 (1 active), ip_addr_of_client:63074 -> ip_addr_of_server, No such file or directory (500 Internal Server Error) How can I debug the connection between httpd and gunicorn? |
|
|||
Quote:
Thank you for your input. I tried it with the setting you suggested and the result is 500. Then I realized maybe my location is wrong. I changed and tried variations of configuration and got a different error code. Code:
prefork 3 server "www.example.com" { listen on * port 80 location "/cython_test/*" { #tried this socket path first then tried the one below #fastcgi socket "/var/www/run/gunicorn.sock" #second socket path fastcgi socket "/run/gunicorn.sock" #these roots are also tried with every socket path variation above #root "cython_test" root "/" } } types { include "/usr/share/misc/mime.types" } this is my /var/www: Code:
ls -1 /var/www acme bin cache cgi-bin conf cython_test htdocs logs run |
|
||||
The socket file must be read/write by the httpd(8) daemon user, www. For example, this is from the same PHP webserver, where the socket's owner and group are both www:
Code:
$ ls -ld /var/www/run/ drwxr-xr-x 2 root daemon 512 Jul 12 20:22 /var/www/run/ $ ls -l /var/www/run/ total 0 srw-rw---- 1 www www 0 Jul 12 20:22 php-fpm.sock |
|
|||
I got this when I run gunicorn.
Code:
$ ls -l /var/www/run/ total 0 srwxrwxrwx 1 www www 0 date time gunicorn.sock srw-rw---- 1 www www 0 date time slowcgi.sock |
|
|||
When you reload httpd to read the edited httpd.conf, do you see any error messages in the logs?
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
Dear J65nko,
there is actually an interesting thing in here. Both, access.log and error.log files produced different results after I did the changes above. At first my acces.log looks like this: Code:
www.example.com ip_of_client - - [DateTime] "GET / HTTP/1.1" 500 0 www.example.com ip_of_client - - [DateTime] "GET /favicon.ico HTTP/1.1" 500 0 Code:
server www.example.com, client 1 (1 active), ip_of_client -> ip_of_server, No such file or directory (500 Internal Server Error) after I made aforementioned change (location to /cython_test instead of /*), I got this access.log: Code:
www.example.com ip_of_client - - [DateTime] "GET / HTTP/1.1" 403 0 www.example.com ip_of_client - - [DateTime] "GET /login HTTP/1.1" 404 0 Code:
server www.example.com, client 1 (1 active), ip_of_client -> ip_of_server, /index.html (403 Forbidden) server www.example.com, client 1 (1 active), ip_of_client -> ip_of_server, /login (404 Not Found) |
|
|||
Hi again,
I was fixing the dependency issues related to the project. I'm trying to funnel the issues to pinpoint the main problem. Could you guys please give me a hint about permitions? So far I have a 1-)project folder inside /var/www, 2-) inside of the project folder, there is a sqlite database file which I should write and read. 3-)inside of the project folder, there is a python virtual environment folder where I run the binaries such as gunicorn etc. 4-) Also the /var/www/run/gunicorn.sock socket. How should I handle chown's and chmod's for them? |
|
|||
I don't know anything about FLASK and Gunicorn, but I wonder why you want to install all that stuff (including a SQLite database) inside /var/www
Starting with the last item, the database: A database like MySQ/MariaDB can be configured to use a 127.0.0.x loopback or a local socket. There is no need for the database files nor its binaries to be inside /var/www at all. If I read https://flask.palletsprojects.com/en...ploying/nginx/ it should be quite easy to run FLASK apps. Remember that the OpenBSD httpd webserver configuration is rather nginx-like. I may be wrong, but aren't you complicating things?
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
Dear J65nko,
Thanks for the input. Yes, I wanted to go with OpenBSD base tools and now I understand it is complicated for me at least. The SQLite choice was for demonstration purposes. For the production, I decided to use MariaDB. Thanks for the suggesting nginx, I already knew nginx was out there but I wanted to make it with httpd. Anyways, thanks for helping me so far. If I come up with a solution, I'll post it in here. Best regards. |
|
|||
I did not want you to switch to nginx. I just wanted to point out that the configuration could be simple. OpenBSD's native httpd is fine.
Nginx used to be in OpenBSD base. Later on it was replaced by httpd that was written from scratch by Reyk Floeter. He decided to use a configuration file with directives that closely resembled the nginx.conf file You could start by getting httpd working with some simple static html pages. Then switch to some simple PHP pages and get that working. There are a lot of tutorials out there that can help you out with that. This will help you to understand how the database, the webserver and PHP work together. Then bring in the stuff like Flask that you really want to work with. Cannot SQLite work with a local socket? https://www.sqlite.org/whentouse.html is very helpful in deciding whether you need a heavier database engine like MariaDB of MySQL.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenSMTP / Dovecot Debugging | smh1 | OpenBSD Packages and Ports | 2 | 29th October 2021 11:34 AM |
Automating the "vi /etc/httpd.conf", httpd -n, rcctl restart httpd" treadmill | J65nko | Guides | 0 | 18th May 2021 12:58 AM |
New httpd and PHP | morophla | OpenBSD Packages and Ports | 21 | 31st August 2015 09:54 PM |
Debugging random restarts | backrow | OpenBSD General | 5 | 21st March 2011 04:58 AM |
Remote debugging Linux kernel | Mr-Biscuit | Other BSD and UNIX/UNIX-like | 0 | 11th December 2008 04:46 AM |