How to run CGI scripts on Nginx
I have problem setting up CGI scripts to be run on Nginx, so far I've found http://wiki.nginx.org/SimpleCGI this stuff but problem is that I can't make perl script run as service so that it will run in background and even in case of restart it will start running automatically
Do you have any idea? I'm running Centos 5
I've found some solutions here but I couldn't integrate code given there with this Perl script
I'm completely zero at Perl, please help me
Thanks
perl nginx cgi centos
add a comment |
I have problem setting up CGI scripts to be run on Nginx, so far I've found http://wiki.nginx.org/SimpleCGI this stuff but problem is that I can't make perl script run as service so that it will run in background and even in case of restart it will start running automatically
Do you have any idea? I'm running Centos 5
I've found some solutions here but I couldn't integrate code given there with this Perl script
I'm completely zero at Perl, please help me
Thanks
perl nginx cgi centos
add a comment |
I have problem setting up CGI scripts to be run on Nginx, so far I've found http://wiki.nginx.org/SimpleCGI this stuff but problem is that I can't make perl script run as service so that it will run in background and even in case of restart it will start running automatically
Do you have any idea? I'm running Centos 5
I've found some solutions here but I couldn't integrate code given there with this Perl script
I'm completely zero at Perl, please help me
Thanks
perl nginx cgi centos
I have problem setting up CGI scripts to be run on Nginx, so far I've found http://wiki.nginx.org/SimpleCGI this stuff but problem is that I can't make perl script run as service so that it will run in background and even in case of restart it will start running automatically
Do you have any idea? I'm running Centos 5
I've found some solutions here but I couldn't integrate code given there with this Perl script
I'm completely zero at Perl, please help me
Thanks
perl nginx cgi centos
perl nginx cgi centos
edited May 23 '17 at 11:47
Community♦
11
11
asked Jul 26 '12 at 10:36
AskhatAskhat
102117
102117
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
Nginx is a web server. You need to use an application server for your task, such as uWSGI for example. It can talk with nginx using its native very effective binary interface called uwsgi.
5
Since the OP is taggedperl
, PSGI/Plack (Perl's WSGI + Rack) is probably what's needed.
– Ashley
Jul 26 '12 at 17:05
2
I'll be darned; just learned uWSGI includes PSGI support, so, nice!
– Ashley
Jul 26 '12 at 17:26
4
Are you saying that Apache and Lighttpd as well as many other are not Web servers because they do support CGI? Using "application server" to run CGI-scripts is an overkill.
– Alex K
Feb 28 '14 at 11:34
1
Apache can be both: an application server and a web-server. It acts as an application server when it runs your web applications. Lighttpd doesn't run CGI itself. It communicates with application using FastCGI protocol, like nginx does.
– VBart
Mar 1 '14 at 21:14
add a comment |
Nginx doesn't have native CGI support (it supports fastCGI instead). The typical solution for this is to run your Perl script as a fastCGI process and edit the nginx config file to re-direct requests to the fastCGI process. This is quite a complex solution if all you want to do is run a CGI script.
Do you have to use nginx for this solution? If all you want to do is execute some Perl CGI scripts, consider using Apache or Lighttpd as they come with CGI modules which will process your CGI scripts natively and don't require the script to be run as a separate process. To do this you need install the web server and edit the web server config file to load the CGI module. For Lighttpd, you will need to add a line in the config file to enable processing of CGI files. Then put the CGI files into the cgi-bin folder.
Thank you for your comment, yes I need to use Nginx because whole web-site is running under Nginx and now I have this(forkosh.com/mimetex.html) CGI script to run under web-site, web-site is Math test so I need support of Mimetex notation, but it is runned only as CGI... so far I've configured to FastCGI for PHP scripts, but it didn't work for simple CGI :( please help...
– Askhat
Jul 26 '12 at 11:27
Although apache and lighttpd come with their own cgi module, the cgi scripts still run in a separate process --- as the web server's child process. Their cgi module only do the work like parsing URL, populating environment variables.
– cli__
Jul 6 '14 at 8:35
Did you ever figure out how to run CGI scripts with NGINX? I have FASTCGI properly set up, but when I run a CGI script, all I see is the script's code.
– trynacode
Jun 26 '16 at 19:16
Thank you! This answer might not help OP but it did help me. By the way, do you have any idea why NGINX didn't even plan to support CGI at all? CGI seems to be a nice fallback for me.
– Franklin Yu
Mar 2 '17 at 19:22
add a comment |
Install another web server(Apache, Lighttpd) that runs on different port. Then proxy your CGI request to the webserver with nginx.
You just need to add this to nginx configuration, after installed a web server on 8080
location /cgi-bin {
proxy_pass http://127.0.0.1:8080;
}
Take a look at Nginx Location Directive Explained for more details.
should I create another instance of web-server on different port? I mean do i need install new instance of Nginx?? or it should be Apache one?
– Askhat
Jul 27 '12 at 12:11
You should install apache, or lighthttpd on different port, then proxy it the cgi-bin folder via nginx.
– Burak Tamtürk
Jul 27 '12 at 12:14
What is the benefit of doing it this way? Why not just run Apache by itself? What benefits does NGINX as the middle layer provide?
– Octopus
Feb 5 '15 at 0:04
You might serving static files or fastcgi while serving some of cgi scripts. Nginx is serving static files and fastcgi related stuffs faster than apache does because of the eventness design of the nginx. Nginx does not execute cgi scripts by the design, since it has to be open a new thread or process for handling the cgi script.
– Burak Tamtürk
Feb 5 '15 at 8:26
add a comment |
I found this hack using FastCGI to be a little nicer than running another web server. http://nginxlibrary.com/perl-fastcgi/
add a comment |
I found this: https://github.com/ruudud/cgi It says:
===
On Ubuntu: apt-get install nginx fcgiwrap
On Arch: pacman -S nginx fcgiwrap
Example Nginx config (Ubuntu: /etc/nginx/sites-enabled/default):
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
location / {
root /srv/static;
autoindex on;
index index.html index.htm;
}
location ~ ^/cgi {
root /srv/my_cgi_app;
rewrite ^/cgi/(.*) /$1 break;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /srv/my_cgi_app$fastcgi_script_name;
}
}
Change the root and fastcgi_param lines to a directory containing CGI scripts, e.g. the cgi-bin/ dir in this repository.
If you are a control freak and run fcgiwrap manually, be sure to change fastcgi_pass accordingly. The path listed in the example is the default in Ubuntu when using the out-of-the-box fcgiwrap setup.
===
I'm about to try it.
1
Hi, Welcome, Maybe you should try and confirm the solution before posting the answer? :)
– Ali
Jan 2 at 4:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11667489%2fhow-to-run-cgi-scripts-on-nginx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Nginx is a web server. You need to use an application server for your task, such as uWSGI for example. It can talk with nginx using its native very effective binary interface called uwsgi.
5
Since the OP is taggedperl
, PSGI/Plack (Perl's WSGI + Rack) is probably what's needed.
– Ashley
Jul 26 '12 at 17:05
2
I'll be darned; just learned uWSGI includes PSGI support, so, nice!
– Ashley
Jul 26 '12 at 17:26
4
Are you saying that Apache and Lighttpd as well as many other are not Web servers because they do support CGI? Using "application server" to run CGI-scripts is an overkill.
– Alex K
Feb 28 '14 at 11:34
1
Apache can be both: an application server and a web-server. It acts as an application server when it runs your web applications. Lighttpd doesn't run CGI itself. It communicates with application using FastCGI protocol, like nginx does.
– VBart
Mar 1 '14 at 21:14
add a comment |
Nginx is a web server. You need to use an application server for your task, such as uWSGI for example. It can talk with nginx using its native very effective binary interface called uwsgi.
5
Since the OP is taggedperl
, PSGI/Plack (Perl's WSGI + Rack) is probably what's needed.
– Ashley
Jul 26 '12 at 17:05
2
I'll be darned; just learned uWSGI includes PSGI support, so, nice!
– Ashley
Jul 26 '12 at 17:26
4
Are you saying that Apache and Lighttpd as well as many other are not Web servers because they do support CGI? Using "application server" to run CGI-scripts is an overkill.
– Alex K
Feb 28 '14 at 11:34
1
Apache can be both: an application server and a web-server. It acts as an application server when it runs your web applications. Lighttpd doesn't run CGI itself. It communicates with application using FastCGI protocol, like nginx does.
– VBart
Mar 1 '14 at 21:14
add a comment |
Nginx is a web server. You need to use an application server for your task, such as uWSGI for example. It can talk with nginx using its native very effective binary interface called uwsgi.
Nginx is a web server. You need to use an application server for your task, such as uWSGI for example. It can talk with nginx using its native very effective binary interface called uwsgi.
edited Jul 26 '12 at 21:33
answered Jul 26 '12 at 11:55
VBartVBart
12.2k23244
12.2k23244
5
Since the OP is taggedperl
, PSGI/Plack (Perl's WSGI + Rack) is probably what's needed.
– Ashley
Jul 26 '12 at 17:05
2
I'll be darned; just learned uWSGI includes PSGI support, so, nice!
– Ashley
Jul 26 '12 at 17:26
4
Are you saying that Apache and Lighttpd as well as many other are not Web servers because they do support CGI? Using "application server" to run CGI-scripts is an overkill.
– Alex K
Feb 28 '14 at 11:34
1
Apache can be both: an application server and a web-server. It acts as an application server when it runs your web applications. Lighttpd doesn't run CGI itself. It communicates with application using FastCGI protocol, like nginx does.
– VBart
Mar 1 '14 at 21:14
add a comment |
5
Since the OP is taggedperl
, PSGI/Plack (Perl's WSGI + Rack) is probably what's needed.
– Ashley
Jul 26 '12 at 17:05
2
I'll be darned; just learned uWSGI includes PSGI support, so, nice!
– Ashley
Jul 26 '12 at 17:26
4
Are you saying that Apache and Lighttpd as well as many other are not Web servers because they do support CGI? Using "application server" to run CGI-scripts is an overkill.
– Alex K
Feb 28 '14 at 11:34
1
Apache can be both: an application server and a web-server. It acts as an application server when it runs your web applications. Lighttpd doesn't run CGI itself. It communicates with application using FastCGI protocol, like nginx does.
– VBart
Mar 1 '14 at 21:14
5
5
Since the OP is tagged
perl
, PSGI/Plack (Perl's WSGI + Rack) is probably what's needed.– Ashley
Jul 26 '12 at 17:05
Since the OP is tagged
perl
, PSGI/Plack (Perl's WSGI + Rack) is probably what's needed.– Ashley
Jul 26 '12 at 17:05
2
2
I'll be darned; just learned uWSGI includes PSGI support, so, nice!
– Ashley
Jul 26 '12 at 17:26
I'll be darned; just learned uWSGI includes PSGI support, so, nice!
– Ashley
Jul 26 '12 at 17:26
4
4
Are you saying that Apache and Lighttpd as well as many other are not Web servers because they do support CGI? Using "application server" to run CGI-scripts is an overkill.
– Alex K
Feb 28 '14 at 11:34
Are you saying that Apache and Lighttpd as well as many other are not Web servers because they do support CGI? Using "application server" to run CGI-scripts is an overkill.
– Alex K
Feb 28 '14 at 11:34
1
1
Apache can be both: an application server and a web-server. It acts as an application server when it runs your web applications. Lighttpd doesn't run CGI itself. It communicates with application using FastCGI protocol, like nginx does.
– VBart
Mar 1 '14 at 21:14
Apache can be both: an application server and a web-server. It acts as an application server when it runs your web applications. Lighttpd doesn't run CGI itself. It communicates with application using FastCGI protocol, like nginx does.
– VBart
Mar 1 '14 at 21:14
add a comment |
Nginx doesn't have native CGI support (it supports fastCGI instead). The typical solution for this is to run your Perl script as a fastCGI process and edit the nginx config file to re-direct requests to the fastCGI process. This is quite a complex solution if all you want to do is run a CGI script.
Do you have to use nginx for this solution? If all you want to do is execute some Perl CGI scripts, consider using Apache or Lighttpd as they come with CGI modules which will process your CGI scripts natively and don't require the script to be run as a separate process. To do this you need install the web server and edit the web server config file to load the CGI module. For Lighttpd, you will need to add a line in the config file to enable processing of CGI files. Then put the CGI files into the cgi-bin folder.
Thank you for your comment, yes I need to use Nginx because whole web-site is running under Nginx and now I have this(forkosh.com/mimetex.html) CGI script to run under web-site, web-site is Math test so I need support of Mimetex notation, but it is runned only as CGI... so far I've configured to FastCGI for PHP scripts, but it didn't work for simple CGI :( please help...
– Askhat
Jul 26 '12 at 11:27
Although apache and lighttpd come with their own cgi module, the cgi scripts still run in a separate process --- as the web server's child process. Their cgi module only do the work like parsing URL, populating environment variables.
– cli__
Jul 6 '14 at 8:35
Did you ever figure out how to run CGI scripts with NGINX? I have FASTCGI properly set up, but when I run a CGI script, all I see is the script's code.
– trynacode
Jun 26 '16 at 19:16
Thank you! This answer might not help OP but it did help me. By the way, do you have any idea why NGINX didn't even plan to support CGI at all? CGI seems to be a nice fallback for me.
– Franklin Yu
Mar 2 '17 at 19:22
add a comment |
Nginx doesn't have native CGI support (it supports fastCGI instead). The typical solution for this is to run your Perl script as a fastCGI process and edit the nginx config file to re-direct requests to the fastCGI process. This is quite a complex solution if all you want to do is run a CGI script.
Do you have to use nginx for this solution? If all you want to do is execute some Perl CGI scripts, consider using Apache or Lighttpd as they come with CGI modules which will process your CGI scripts natively and don't require the script to be run as a separate process. To do this you need install the web server and edit the web server config file to load the CGI module. For Lighttpd, you will need to add a line in the config file to enable processing of CGI files. Then put the CGI files into the cgi-bin folder.
Thank you for your comment, yes I need to use Nginx because whole web-site is running under Nginx and now I have this(forkosh.com/mimetex.html) CGI script to run under web-site, web-site is Math test so I need support of Mimetex notation, but it is runned only as CGI... so far I've configured to FastCGI for PHP scripts, but it didn't work for simple CGI :( please help...
– Askhat
Jul 26 '12 at 11:27
Although apache and lighttpd come with their own cgi module, the cgi scripts still run in a separate process --- as the web server's child process. Their cgi module only do the work like parsing URL, populating environment variables.
– cli__
Jul 6 '14 at 8:35
Did you ever figure out how to run CGI scripts with NGINX? I have FASTCGI properly set up, but when I run a CGI script, all I see is the script's code.
– trynacode
Jun 26 '16 at 19:16
Thank you! This answer might not help OP but it did help me. By the way, do you have any idea why NGINX didn't even plan to support CGI at all? CGI seems to be a nice fallback for me.
– Franklin Yu
Mar 2 '17 at 19:22
add a comment |
Nginx doesn't have native CGI support (it supports fastCGI instead). The typical solution for this is to run your Perl script as a fastCGI process and edit the nginx config file to re-direct requests to the fastCGI process. This is quite a complex solution if all you want to do is run a CGI script.
Do you have to use nginx for this solution? If all you want to do is execute some Perl CGI scripts, consider using Apache or Lighttpd as they come with CGI modules which will process your CGI scripts natively and don't require the script to be run as a separate process. To do this you need install the web server and edit the web server config file to load the CGI module. For Lighttpd, you will need to add a line in the config file to enable processing of CGI files. Then put the CGI files into the cgi-bin folder.
Nginx doesn't have native CGI support (it supports fastCGI instead). The typical solution for this is to run your Perl script as a fastCGI process and edit the nginx config file to re-direct requests to the fastCGI process. This is quite a complex solution if all you want to do is run a CGI script.
Do you have to use nginx for this solution? If all you want to do is execute some Perl CGI scripts, consider using Apache or Lighttpd as they come with CGI modules which will process your CGI scripts natively and don't require the script to be run as a separate process. To do this you need install the web server and edit the web server config file to load the CGI module. For Lighttpd, you will need to add a line in the config file to enable processing of CGI files. Then put the CGI files into the cgi-bin folder.
answered Jul 26 '12 at 11:22


David FarrellDavid Farrell
554314
554314
Thank you for your comment, yes I need to use Nginx because whole web-site is running under Nginx and now I have this(forkosh.com/mimetex.html) CGI script to run under web-site, web-site is Math test so I need support of Mimetex notation, but it is runned only as CGI... so far I've configured to FastCGI for PHP scripts, but it didn't work for simple CGI :( please help...
– Askhat
Jul 26 '12 at 11:27
Although apache and lighttpd come with their own cgi module, the cgi scripts still run in a separate process --- as the web server's child process. Their cgi module only do the work like parsing URL, populating environment variables.
– cli__
Jul 6 '14 at 8:35
Did you ever figure out how to run CGI scripts with NGINX? I have FASTCGI properly set up, but when I run a CGI script, all I see is the script's code.
– trynacode
Jun 26 '16 at 19:16
Thank you! This answer might not help OP but it did help me. By the way, do you have any idea why NGINX didn't even plan to support CGI at all? CGI seems to be a nice fallback for me.
– Franklin Yu
Mar 2 '17 at 19:22
add a comment |
Thank you for your comment, yes I need to use Nginx because whole web-site is running under Nginx and now I have this(forkosh.com/mimetex.html) CGI script to run under web-site, web-site is Math test so I need support of Mimetex notation, but it is runned only as CGI... so far I've configured to FastCGI for PHP scripts, but it didn't work for simple CGI :( please help...
– Askhat
Jul 26 '12 at 11:27
Although apache and lighttpd come with their own cgi module, the cgi scripts still run in a separate process --- as the web server's child process. Their cgi module only do the work like parsing URL, populating environment variables.
– cli__
Jul 6 '14 at 8:35
Did you ever figure out how to run CGI scripts with NGINX? I have FASTCGI properly set up, but when I run a CGI script, all I see is the script's code.
– trynacode
Jun 26 '16 at 19:16
Thank you! This answer might not help OP but it did help me. By the way, do you have any idea why NGINX didn't even plan to support CGI at all? CGI seems to be a nice fallback for me.
– Franklin Yu
Mar 2 '17 at 19:22
Thank you for your comment, yes I need to use Nginx because whole web-site is running under Nginx and now I have this(forkosh.com/mimetex.html) CGI script to run under web-site, web-site is Math test so I need support of Mimetex notation, but it is runned only as CGI... so far I've configured to FastCGI for PHP scripts, but it didn't work for simple CGI :( please help...
– Askhat
Jul 26 '12 at 11:27
Thank you for your comment, yes I need to use Nginx because whole web-site is running under Nginx and now I have this(forkosh.com/mimetex.html) CGI script to run under web-site, web-site is Math test so I need support of Mimetex notation, but it is runned only as CGI... so far I've configured to FastCGI for PHP scripts, but it didn't work for simple CGI :( please help...
– Askhat
Jul 26 '12 at 11:27
Although apache and lighttpd come with their own cgi module, the cgi scripts still run in a separate process --- as the web server's child process. Their cgi module only do the work like parsing URL, populating environment variables.
– cli__
Jul 6 '14 at 8:35
Although apache and lighttpd come with their own cgi module, the cgi scripts still run in a separate process --- as the web server's child process. Their cgi module only do the work like parsing URL, populating environment variables.
– cli__
Jul 6 '14 at 8:35
Did you ever figure out how to run CGI scripts with NGINX? I have FASTCGI properly set up, but when I run a CGI script, all I see is the script's code.
– trynacode
Jun 26 '16 at 19:16
Did you ever figure out how to run CGI scripts with NGINX? I have FASTCGI properly set up, but when I run a CGI script, all I see is the script's code.
– trynacode
Jun 26 '16 at 19:16
Thank you! This answer might not help OP but it did help me. By the way, do you have any idea why NGINX didn't even plan to support CGI at all? CGI seems to be a nice fallback for me.
– Franklin Yu
Mar 2 '17 at 19:22
Thank you! This answer might not help OP but it did help me. By the way, do you have any idea why NGINX didn't even plan to support CGI at all? CGI seems to be a nice fallback for me.
– Franklin Yu
Mar 2 '17 at 19:22
add a comment |
Install another web server(Apache, Lighttpd) that runs on different port. Then proxy your CGI request to the webserver with nginx.
You just need to add this to nginx configuration, after installed a web server on 8080
location /cgi-bin {
proxy_pass http://127.0.0.1:8080;
}
Take a look at Nginx Location Directive Explained for more details.
should I create another instance of web-server on different port? I mean do i need install new instance of Nginx?? or it should be Apache one?
– Askhat
Jul 27 '12 at 12:11
You should install apache, or lighthttpd on different port, then proxy it the cgi-bin folder via nginx.
– Burak Tamtürk
Jul 27 '12 at 12:14
What is the benefit of doing it this way? Why not just run Apache by itself? What benefits does NGINX as the middle layer provide?
– Octopus
Feb 5 '15 at 0:04
You might serving static files or fastcgi while serving some of cgi scripts. Nginx is serving static files and fastcgi related stuffs faster than apache does because of the eventness design of the nginx. Nginx does not execute cgi scripts by the design, since it has to be open a new thread or process for handling the cgi script.
– Burak Tamtürk
Feb 5 '15 at 8:26
add a comment |
Install another web server(Apache, Lighttpd) that runs on different port. Then proxy your CGI request to the webserver with nginx.
You just need to add this to nginx configuration, after installed a web server on 8080
location /cgi-bin {
proxy_pass http://127.0.0.1:8080;
}
Take a look at Nginx Location Directive Explained for more details.
should I create another instance of web-server on different port? I mean do i need install new instance of Nginx?? or it should be Apache one?
– Askhat
Jul 27 '12 at 12:11
You should install apache, or lighthttpd on different port, then proxy it the cgi-bin folder via nginx.
– Burak Tamtürk
Jul 27 '12 at 12:14
What is the benefit of doing it this way? Why not just run Apache by itself? What benefits does NGINX as the middle layer provide?
– Octopus
Feb 5 '15 at 0:04
You might serving static files or fastcgi while serving some of cgi scripts. Nginx is serving static files and fastcgi related stuffs faster than apache does because of the eventness design of the nginx. Nginx does not execute cgi scripts by the design, since it has to be open a new thread or process for handling the cgi script.
– Burak Tamtürk
Feb 5 '15 at 8:26
add a comment |
Install another web server(Apache, Lighttpd) that runs on different port. Then proxy your CGI request to the webserver with nginx.
You just need to add this to nginx configuration, after installed a web server on 8080
location /cgi-bin {
proxy_pass http://127.0.0.1:8080;
}
Take a look at Nginx Location Directive Explained for more details.
Install another web server(Apache, Lighttpd) that runs on different port. Then proxy your CGI request to the webserver with nginx.
You just need to add this to nginx configuration, after installed a web server on 8080
location /cgi-bin {
proxy_pass http://127.0.0.1:8080;
}
Take a look at Nginx Location Directive Explained for more details.
edited Dec 30 '18 at 3:04


mbigras
2,57052265
2,57052265
answered Jul 26 '12 at 12:02
Burak TamtürkBurak Tamtürk
1,013616
1,013616
should I create another instance of web-server on different port? I mean do i need install new instance of Nginx?? or it should be Apache one?
– Askhat
Jul 27 '12 at 12:11
You should install apache, or lighthttpd on different port, then proxy it the cgi-bin folder via nginx.
– Burak Tamtürk
Jul 27 '12 at 12:14
What is the benefit of doing it this way? Why not just run Apache by itself? What benefits does NGINX as the middle layer provide?
– Octopus
Feb 5 '15 at 0:04
You might serving static files or fastcgi while serving some of cgi scripts. Nginx is serving static files and fastcgi related stuffs faster than apache does because of the eventness design of the nginx. Nginx does not execute cgi scripts by the design, since it has to be open a new thread or process for handling the cgi script.
– Burak Tamtürk
Feb 5 '15 at 8:26
add a comment |
should I create another instance of web-server on different port? I mean do i need install new instance of Nginx?? or it should be Apache one?
– Askhat
Jul 27 '12 at 12:11
You should install apache, or lighthttpd on different port, then proxy it the cgi-bin folder via nginx.
– Burak Tamtürk
Jul 27 '12 at 12:14
What is the benefit of doing it this way? Why not just run Apache by itself? What benefits does NGINX as the middle layer provide?
– Octopus
Feb 5 '15 at 0:04
You might serving static files or fastcgi while serving some of cgi scripts. Nginx is serving static files and fastcgi related stuffs faster than apache does because of the eventness design of the nginx. Nginx does not execute cgi scripts by the design, since it has to be open a new thread or process for handling the cgi script.
– Burak Tamtürk
Feb 5 '15 at 8:26
should I create another instance of web-server on different port? I mean do i need install new instance of Nginx?? or it should be Apache one?
– Askhat
Jul 27 '12 at 12:11
should I create another instance of web-server on different port? I mean do i need install new instance of Nginx?? or it should be Apache one?
– Askhat
Jul 27 '12 at 12:11
You should install apache, or lighthttpd on different port, then proxy it the cgi-bin folder via nginx.
– Burak Tamtürk
Jul 27 '12 at 12:14
You should install apache, or lighthttpd on different port, then proxy it the cgi-bin folder via nginx.
– Burak Tamtürk
Jul 27 '12 at 12:14
What is the benefit of doing it this way? Why not just run Apache by itself? What benefits does NGINX as the middle layer provide?
– Octopus
Feb 5 '15 at 0:04
What is the benefit of doing it this way? Why not just run Apache by itself? What benefits does NGINX as the middle layer provide?
– Octopus
Feb 5 '15 at 0:04
You might serving static files or fastcgi while serving some of cgi scripts. Nginx is serving static files and fastcgi related stuffs faster than apache does because of the eventness design of the nginx. Nginx does not execute cgi scripts by the design, since it has to be open a new thread or process for handling the cgi script.
– Burak Tamtürk
Feb 5 '15 at 8:26
You might serving static files or fastcgi while serving some of cgi scripts. Nginx is serving static files and fastcgi related stuffs faster than apache does because of the eventness design of the nginx. Nginx does not execute cgi scripts by the design, since it has to be open a new thread or process for handling the cgi script.
– Burak Tamtürk
Feb 5 '15 at 8:26
add a comment |
I found this hack using FastCGI to be a little nicer than running another web server. http://nginxlibrary.com/perl-fastcgi/
add a comment |
I found this hack using FastCGI to be a little nicer than running another web server. http://nginxlibrary.com/perl-fastcgi/
add a comment |
I found this hack using FastCGI to be a little nicer than running another web server. http://nginxlibrary.com/perl-fastcgi/
I found this hack using FastCGI to be a little nicer than running another web server. http://nginxlibrary.com/perl-fastcgi/
answered Nov 8 '17 at 18:28
Alton YuAlton Yu
211
211
add a comment |
add a comment |
I found this: https://github.com/ruudud/cgi It says:
===
On Ubuntu: apt-get install nginx fcgiwrap
On Arch: pacman -S nginx fcgiwrap
Example Nginx config (Ubuntu: /etc/nginx/sites-enabled/default):
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
location / {
root /srv/static;
autoindex on;
index index.html index.htm;
}
location ~ ^/cgi {
root /srv/my_cgi_app;
rewrite ^/cgi/(.*) /$1 break;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /srv/my_cgi_app$fastcgi_script_name;
}
}
Change the root and fastcgi_param lines to a directory containing CGI scripts, e.g. the cgi-bin/ dir in this repository.
If you are a control freak and run fcgiwrap manually, be sure to change fastcgi_pass accordingly. The path listed in the example is the default in Ubuntu when using the out-of-the-box fcgiwrap setup.
===
I'm about to try it.
1
Hi, Welcome, Maybe you should try and confirm the solution before posting the answer? :)
– Ali
Jan 2 at 4:18
add a comment |
I found this: https://github.com/ruudud/cgi It says:
===
On Ubuntu: apt-get install nginx fcgiwrap
On Arch: pacman -S nginx fcgiwrap
Example Nginx config (Ubuntu: /etc/nginx/sites-enabled/default):
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
location / {
root /srv/static;
autoindex on;
index index.html index.htm;
}
location ~ ^/cgi {
root /srv/my_cgi_app;
rewrite ^/cgi/(.*) /$1 break;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /srv/my_cgi_app$fastcgi_script_name;
}
}
Change the root and fastcgi_param lines to a directory containing CGI scripts, e.g. the cgi-bin/ dir in this repository.
If you are a control freak and run fcgiwrap manually, be sure to change fastcgi_pass accordingly. The path listed in the example is the default in Ubuntu when using the out-of-the-box fcgiwrap setup.
===
I'm about to try it.
1
Hi, Welcome, Maybe you should try and confirm the solution before posting the answer? :)
– Ali
Jan 2 at 4:18
add a comment |
I found this: https://github.com/ruudud/cgi It says:
===
On Ubuntu: apt-get install nginx fcgiwrap
On Arch: pacman -S nginx fcgiwrap
Example Nginx config (Ubuntu: /etc/nginx/sites-enabled/default):
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
location / {
root /srv/static;
autoindex on;
index index.html index.htm;
}
location ~ ^/cgi {
root /srv/my_cgi_app;
rewrite ^/cgi/(.*) /$1 break;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /srv/my_cgi_app$fastcgi_script_name;
}
}
Change the root and fastcgi_param lines to a directory containing CGI scripts, e.g. the cgi-bin/ dir in this repository.
If you are a control freak and run fcgiwrap manually, be sure to change fastcgi_pass accordingly. The path listed in the example is the default in Ubuntu when using the out-of-the-box fcgiwrap setup.
===
I'm about to try it.
I found this: https://github.com/ruudud/cgi It says:
===
On Ubuntu: apt-get install nginx fcgiwrap
On Arch: pacman -S nginx fcgiwrap
Example Nginx config (Ubuntu: /etc/nginx/sites-enabled/default):
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
location / {
root /srv/static;
autoindex on;
index index.html index.htm;
}
location ~ ^/cgi {
root /srv/my_cgi_app;
rewrite ^/cgi/(.*) /$1 break;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /srv/my_cgi_app$fastcgi_script_name;
}
}
Change the root and fastcgi_param lines to a directory containing CGI scripts, e.g. the cgi-bin/ dir in this repository.
If you are a control freak and run fcgiwrap manually, be sure to change fastcgi_pass accordingly. The path listed in the example is the default in Ubuntu when using the out-of-the-box fcgiwrap setup.
===
I'm about to try it.
answered Jan 2 at 4:07
Brad AllenBrad Allen
111
111
1
Hi, Welcome, Maybe you should try and confirm the solution before posting the answer? :)
– Ali
Jan 2 at 4:18
add a comment |
1
Hi, Welcome, Maybe you should try and confirm the solution before posting the answer? :)
– Ali
Jan 2 at 4:18
1
1
Hi, Welcome, Maybe you should try and confirm the solution before posting the answer? :)
– Ali
Jan 2 at 4:18
Hi, Welcome, Maybe you should try and confirm the solution before posting the answer? :)
– Ali
Jan 2 at 4:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11667489%2fhow-to-run-cgi-scripts-on-nginx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown