Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx improvements #36

Merged
merged 1 commit into from
Sep 20, 2022
Merged

Nginx improvements #36

merged 1 commit into from
Sep 20, 2022

Conversation

iliajie
Copy link
Contributor

@iliajie iliajie commented Sep 19, 2022

Jamie, I was running more tests today on Nginx module and found few bugs:

  1. When PHP execution mode is set to Disabled, PHP files where downloaded instead of shown as text due to incorrect mime type. Fixed on this commit in this PR - cf6a0ec
  2. Even though FCGIWrap systemd unit is setup correctly, the scripts are not executed (i.e. under /cgi-bin directory) and an error always displayed:
    image
  3. If a template has Disabled set for PHP execution mode then still a newly created website has FCGId setup by default (when should be Disabled as defined on the template)

Can you please pull this branch and check in a fix for #2 and #3 please? Also, check if #1 looks good to you as it works perfectly fine for me.

@jcameron jcameron merged commit aa440d7 into master Sep 20, 2022
@jcameron
Copy link
Collaborator

Regarding (2), which Linux distribution did you see this on? And did anything useful get written to logs/error_log ?

@iliajie
Copy link
Contributor Author

iliajie commented Sep 20, 2022

That was AlmaLinux. I don't remember exactly about errors in Nginx logs. But this error usually means that either a service isn't running or something is misconfigured under /cgi-bin location in a server config.

@jcameron
Copy link
Collaborator

Did you only see this on AlmaLinux?

@iliajie
Copy link
Contributor Author

iliajie commented Sep 20, 2022

Did you only see this on AlmaLinux?

I see it on both Alma 9 and Ubuntu 22.04 with Nginx.

However, I just found a "problem", as when you run scripts under Nginx it returns damn super confusing error (502 bad gateway), unless you don't print first print "Content-Type: text/html\n\n"; or even print " \n\n"; works which makes it even more ridiculous.

i.e. test.cgi and fcgiwrap with Apache and the following works:

#!/usr/bin/perl

print "Hello World";

However, under Nginx it prints misleading error in ~/logs/fcgiwrap.log:

Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?

.. which makes absolutely no sense! It took me some time to understand what was really wrong. However, just "sending headers" with print "Content-Type: text/html\n\n"; makes it work with Nginx as well:

#!/usr/bin/perl

print "Content-Type: text/html\n\n";
print "Hello World";

.. and more ridiculous this works too:

#!/usr/bin/perl

print " \n\n";
print "Hello World";

.. but why? And isn't that sick that the error message produced is so misleading? I know it's not our problem but still.

@jcameron
Copy link
Collaborator

That's kind of expected - all CGI scripts must output proper headers. If not, the fcgiwrap server probably just fails to process the output and returns an error to Nginx.

@jcameron
Copy link
Collaborator

As for issue #3, it should be fixed by 7e65268

@iliajie
Copy link
Contributor Author

iliajie commented Sep 21, 2022

That's kind of expected - all CGI scripts must output proper headers.

Yes, yes I'm aware of that but the error message is deceptive!

As for issue #3, it should be fixed by 7e65268

That works, thanks!

@iliajie iliajie deleted the dev/nginx-improvements branch September 21, 2022 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants