How to configure with nginx, fastcgi, and fcgiwrap?
(1) By anonymous on 2019-08-23 21:16:47 [link] [source]
Hello everyone. I am attempting to deploy Fossil for use at our local office on an Ubuntu Linux cloud server, which runs the nginx web server. To facilitate the CGI interface, I've installed the fastcgi wrapper fcgiwrapper; however, I'm not having any luck getting things working.
Would anyone have a working example that I can use as a template for my own installation? Otherwise, if anyone wants to know our specific configurations, how may I best communicate that?
The goal is to install a Fossil repo at the URL http://10.20.30.40/repos/tickets (where repos is my CGI-bin directory and tickets is a shell script that reads as below).
#!/usr/bin/fossil
repository: /home/fossil/tickets.fossil
errorlog: /var/log/fossil.err
However, /var/log/fossil.err never is created, no errors are generated in /var/log/nginx/error.log. From nginx's perspective, everything is going through OK. Yet, I see the response, "Not Found Page not found: repos".
Thanks for any pointers you might be able to provide.
(2) By Richard Hipp (drh) on 2019-08-23 21:45:54 in reply to 1 [source]
I've never used (or heard of) fcgiwrapper. So I have no personal experience. But my suggestion is that you first verify that fcgiwrapper really is working by replacing the CGI script with something like this:
#!/bin/sh echo 'Content-Type: text/plain' echo '' env | sort
If you install the above script, and it works, then visiting the page should show you your CGI environment. Please try it. If that doesn't work, try something even simpler, like this:
#!/bin/sh echo 'Content-Type: text/plain' echo '' echo 'Hello, World!'
Fiddle around with those scripts until you get them working, then move on to trying to get Fossil up and running.
(3) By Samuel A. Falvo II (KC5TJA) (kc5tja) on 2019-08-26 21:03:19 in reply to 2 [link] [source]
Thank you for the suggestion. I've tried this, and the shell script successfully emits the hello world message to the web browser.
On the plus side of things, it looks like the FCGI configuration works. :)
I then reviewed this checklist to see if there might be any problems, but this is what I've found. I've determined that fcgiwrap runs as a user called www-data based on configurations found in /etc/init.d.
Also, I forgot to mention the version I've installed is quite recent:
# fossil version
This is fossil version 2.9 [0fd79a3e09] 2019-07-13 13:05:19 UTC
The Fossil binary must be readable/executable by the process which executes the CGI.
-rwxr-xr-x 1 root root 6762104 Jul 13 13:21 /usr/bin/fossil
All directories leading up to the Fossil binary must be readable by the process which executes the CGI.
drwxr-xr-x 23 root root 4096 Aug 23 18:40 /
drwxr-xr-x 10 root root 4096 Dec 22 2018 /usr
drwxr-xr-x 2 root root 20480 Aug 23 19:31 /usr/bin
The CGI script must be executable for the user under which it will run, which often differs from the one running the web server. Consult your site's documentation or the web server’s system administrator.
-rwxr-xr-x 1 root root 89 Aug 26 20:41 tickets
All directories leading to the CGI script must be readable by the web server.
drwxr-xr-x 23 root root 4096 Aug 23 18:40 /
drwxr-xr-x 14 root root 4096 Mar 2 22:30 /var
drwxr-xr-x 4 root root 4096 Aug 23 18:57 /var/www
drwxr-xr-x 3 root root 4096 Aug 23 19:26 /var/www/csr.electriqpower.com
drwxr-xr-x 2 root root 4096 Aug 26 20:41 /var/www/csr.electriqpower.com/repos
The repository file and the directory containing it must be writable by the same account which executes the Fossil binary.
drwxrwxr-x 2 fossil www-data 4096 Aug 26 20:56 fossil
-rw-rw-r-- 1 fossil www-data 229376 Aug 26 20:56 fossil/tickets.fossil
It seems to me that I'm meeting the checklist pretty well. Still, fossil seems to be reporting that "repos" cannot be found. It's not clear to me why, since "repos" never appears in the configured CGI script:
#!/usr/bin/fossil
repository: /home/fossil/tickets.fossil
errorlog: /var/log/fossil.err
It does, however, appear in a pathname where the CGI script is stored: /var/www/csr.electriqpower.com/repos/tickets; but the only reason I have created repos/ in the first place is because I couldn't get the CGI script to run at all when co-residing with the index.html page. :/
I guess I'll keep hacking away at this; but if anyone has any ideas on what to check next, I'd be appreciative. Thanks for taking the time!
(4) By Richard Hipp (drh) on 2019-08-26 22:07:50 in reply to 3 [link] [source]
Please try the "hello world" script again, or better, the script that shows
your environment. But when you access it, add a few extra terms onto the
end of the pathname in the URL. Something simple, like ".../abc/def/xyz".
Let me know
if it still works. If it does work, please post the environment listing.
(There shouldn't be anything security-sensitive in the environment, but you
should review it and redact anything that seems inappropriate.)
(5) By anonymous on 2019-08-28 03:08:42 in reply to 4 [link] [source]
N.B.: Apologies for posting as anonymous again. I'm working from two different machines, and my password manager stored this site's password in a folder specific for that machine, which I didn't realize at the time I created my account. As I'm on my laptop at the moment, I don't have access to that private folder. I'll migrate my password configs tomorrow when I'm back in the office. Apologies for any confusion.
Thanks for taking the time to look. The environment as I currently see it:
HTTP_HOST=csr.electriqpower.com
LANG=C.UTF-8
INVOCATION_ID=6664c535918749f4a4748e2f70a77763
HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
FCGI_ROLE=RESPONDER
SERVER_PORT=80
USER=www-data
SERVER_NAME=csr.electriqpower.com
QUERY_STRING=ghi=jkl&mno=pqr
SCRIPT_FILENAME=/var/www/csr.electriqpower.com/repos/tickets
PWD=/var/www/csr.electriqpower.com/repos
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HOME=/var/www
JOURNAL_STREAM=9:24304
CONTENT_TYPE=
REDIRECT_STATUS=200
DOCUMENT_URI=/repos/tickets/abc/def
REQUEST_METHOD=GET
SCRIPT_NAME=tickets
HTTP_CONNECTION=keep-alive
REMOTE_PORT=33862
DAEMON_OPTS=-f
SHLVL=1
SERVER_PROTOCOL=HTTP/1.1
HTTP_COOKIE=_ga=GA1.2.1335526678.1530120233; __hstc=241594461.19326094ab91ee63a189350480e67102.1530120233616.1557259292159.1564625070733.3; hubspotutk=19326094ab91ee63a189350480e67102; _fbp=fb.1.1557259292542.80333820
REQUEST_URI=/repos/tickets/abc/def?ghi=jkl&mno=pqr
HTTP_ACCEPT_LANGUAGE=en-US,en;q=0.5
LOGNAME=www-data
HTTP_UPGRADE_INSECURE_REQUESTS=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SERVER_ADDR=104.130.201.104
GATEWAY_INTERFACE=CGI/1.1
HTTP_ACCEPT_ENCODING=gzip, deflate
REQUEST_SCHEME=http
REMOTE_ADDR=173.11.86.22
CONTENT_LENGTH=
SERVER_SOFTWARE=nginx/1.14.0
_=/usr/bin/env
I'm hoping that this is something pretty silly and easily overlooked.