Hi,
I'd like to rewrite every request to xxx.html unless they are coming from my
2 trusted IP addresses. What can I do?
In the mean time, I need to avoid the loop to request the xxx.html.
Any example appreciated.
pahud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090625/f28a70a2/attachment.html>
Can you add basic authentication to a symlink in the web directory? I tried it but I don?t get a prompt. Just want to check if it?s possible before I start troubleshooting my config. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090625/d620a4ee/attachment.html>
Hello!
On Thu, Jun 25, 2009 at 11:08:48AM -0500, AMP Admin wrote:
> Can you add basic authentication to a symlink in the web directory? I tried it but I don?t get a prompt. Just want to check if it?s possible before I start troubleshooting my config. Thanks.
It should work as long as nginx doesn't distinguish symlinks from
real files/directories.
Maxim Dounin
Hello!
On Thu, Jun 25, 2009 at 01:03:24PM +0800, Pahud wrote:
> Hi,
>
> I'd like to rewrite every request to xxx.html unless they are coming from my
> 2 trusted IP addresses. What can I do?
>
> In the mean time, I need to avoid the loop to request the xxx.html.
>
> Any example appreciated.
Something like this should work:
location / {
error_page 403 =200 /xxx.html;
allow 1.2.3.4;
allow 1.2.3.5;
deny all;
...
}
location = /xxx.html {
# an empty location without access checks
}
Maxim Dounin
>
> pahud
I'm not sure if it does or not.
-----Original Message-----
From: owner-nginx at sysoev.ru [mailto:owner-nginx at sysoev.ru] On Behalf Of Maxim Dounin
Sent: Thursday, June 25, 2009 11:35 AM
To: nginx at sysoev.ru
Subject: Re: basic auth symlink
Hello!
On Thu, Jun 25, 2009 at 11:08:48AM -0500, AMP Admin wrote:
> Can you add basic authentication to a symlink in the web directory? I tried it but I don?t get a prompt. Just want to check if it?s possible before I start troubleshooting my config. Thanks.
It should work as long as nginx doesn't distinguish symlinks from
real files/directories.
Maxim Dounin
Hello!
On Thu, Jun 25, 2009 at 11:56:01AM -0500, AMP Admin wrote:
> I'm not sure if it does or not.
It doesn't.
Maxim Dounin
>
> -----Original Message-----
> From: owner-nginx at sysoev.ru [mailto:owner-nginx at sysoev.ru] On Behalf Of Maxim Dounin
> Sent: Thursday, June 25, 2009 11:35 AM
> To: nginx at sysoev.ru
> Subject: Re: basic auth symlink
>
> Hello!
>
> On Thu, Jun 25, 2009 at 11:08:48AM -0500, AMP Admin wrote:
>
> > Can you add basic authentication to a symlink in the web directory? I tried it but I don?t get a prompt. Just want to check if it?s possible before I start troubleshooting my config. Thanks.
>
> It should work as long as nginx doesn't distinguish symlinks from
> real files/directories.
>
> Maxim Dounin
>
>
I'm trying to get the "Easy PHP Version" for processing cgi-bin (http://wiki.nginx.org//NginxSimpleCGI) but I can't seem to get it right.
The following keeps returning 404. I know the file is there because when I remove the following it prompts me to download the file.
### CGI ###
location ~ ^/cgi-bin/.*\.(cgi|pl|py|rb) {
gzip off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index cgi-bin.php;
fastcgi_param SCRIPT_FILENAME /etc/nginx/cgi-bin.php;
fastcgi_param SCRIPT_NAME cgi-bin.php;
fastcgi_param X_SCRIPT_FILENAME /var/www/html/cgi-bin/awstats.pl;
fastcgi_param X_SCRIPT_NAME awstats.pl;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_USER $remote_user;
}
### /CGI ###
I see this in the error log:
[error] 30432#0: *1 FastCGI sent in stderr: "PHP Notice: Undefined index: X_SCRIPT_FILENAME in /etc/nginx/cgi-bin.php on line 10
Here is cgi-bin.php:
<?php
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);
$newenv = $_ENV;
$newenv["SCRIPT_FILENAME"] = $_ENV["X_SCRIPT_FILENAME"];
$newenv["SCRIPT_NAME"] = $_ENV["X_SCRIPT_NAME"];
if (is_executable($_ENV["X_SCRIPT_FILENAME"])) {
$process = proc_open($_ENV["X_SCRIPT_FILENAME"], $descriptorspec, $pipes, NULL, $newenv);
if (is_resource($process)) {
fclose($pipes[0]);
$head = fgets($pipes[1]);
while (strcmp($head, "\n")) {
header($head);
$head = fgets($pipes[1]);
}
fpassthru($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
$return_value = proc_close($process);
}
else {
header("Status: 500 Internal Server Error");
echo("Internal Server Error");
}
}
else {
header("Status: 404 Page Not Found");
echo("Page Not Found");
}
?>
So if you put http://example.com/stats it will run your awstats.pl ?
-----Original Message-----
From: owner-nginx at sysoev.ru [mailto:owner-nginx at sysoev.ru] On Behalf Of
Jools Wills
Sent: Saturday, June 27, 2009 5:21 AM
To: nginx at sysoev.ru
Subject: Re: Help Processing a pl script pls
Here is how I handle awstats. I also use fcgiwrap to handle the
fcgi->cgi.
location ~ ^/stats/ {
fastcgi_pass unix:/tmp/cgi.sock;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/awstats.pl;
fastcgi_param SCRIPT_NAME awstats.pl;
fastcgi_param DOCUMENT_ROOT /usr/lib/cgi-bin/;
include fastcgi_params;
auth_basic "Restricted Area";
auth_basic_user_file /etc/apache2/passwords/awstats;
}
location /awstats-icon/ {
alias /usr/share/awstats/icon/;
}
my other params look like
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
# read its better to leave this out for php ?
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_USER $remote_user;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
On Sat, 2009-06-27 at 12:58 -0500, AMP Admin wrote:
> So if you put http://example.com/stats it will run your awstats.pl ?
well /stats/ (with additional slash) but yeh
Best Regards
Jools