18 messages in ru.sysoev.nginxRe: Running Mercurial using Nginx as ...
FromSent OnAttachments
ThomasJan 26, 2008 9:26 am 
Cliff WellsJan 26, 2008 11:14 am 
Adrian PerezJan 27, 2008 5:29 pm 
ThomasJan 29, 2008 2:58 am 
Marcin KasperskiJan 29, 2008 3:49 am 
ThomasJan 29, 2008 1:11 pm 
eliottJan 29, 2008 1:27 pm 
ThomasJan 29, 2008 1:34 pm 
ThomasJan 29, 2008 2:03 pm 
Manlio PerilloJan 29, 2008 2:30 pm 
ThomasJan 29, 2008 2:47 pm 
ThomasJan 29, 2008 3:23 pm 
ThomasJan 30, 2008 4:57 am 
Manlio PerilloJan 30, 2008 5:47 am 
ThomasJan 30, 2008 6:01 am 
ThomasJan 30, 2008 6:33 am 
Manlio PerilloJan 30, 2008 7:16 am 
ThomasMar 17, 2008 5:23 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Running Mercurial using Nginx as http serverActions...
From:Thomas (iamk@public.gmane.org)
Date:Jan 30, 2008 6:01:50 am
List:ru.sysoev.nginx

Today after a hard reboot and purging some files, mercurial has gone back to a normal behavior. I don't need to sudo to issue mercurial commands.

I have been playing with different fastcgi setups with more or less success.

Here are my nginx.conf and fasctgi.conf files:

Nginx.conf:

---------------------------- user www-data www-data; worker_processes 1;

error_log /var/log/nginx/error.log;

pid /var/run/nginx.pid;

events { worker_connections 1024; use epoll; }

http { index index.html; include /etc/nginx/mime.types; default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "http_x_forwarded_for"'; #access_log logs/access.log main;

sendfile on; tcp_nopush on; tcp_nodelay on;

keepalive_timeout 75 20;

ignore_invalid_headers on;

# PhpMyAdmin listening server server { listen 81; #listen 192.168.1.1:8080;

server_name ubuntu;

location / { root /var/www/phpmyadmin; index index.php; }

location ~ \.php$ { include /etc/nginx/fastcgi.conf; fastcgi_pass 127.0.0.1:10005; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/phpmyadmin$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $document_root; } } # End of the server directive

# FastCGI server from nginx.eu server { listen 82; #listen 192.168.1.1:8080;

server_name ubuntu;

location / { root /var/www/mercurial; index index.cgi; }

location ~ \.cgi($|/) { include /etc/nginx/fastcgi.conf;

set $script $uri; set $path_info "";

if ($uri ~ "^(.+\.php)(/.+)") { set $script $1; set $path_info $2; }

#root /var/hg;

proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; fastcgi_pass unix:/var/run/nginx/nginx-fcgi.sock; # fastcgi_pass_header Authorization; # fastcgi_intercept_errors off; fastcgi_param SCRIPT_FILENAME /var/www/mercurial$fastcgi_script_name; # fastcgi_param SCRIPT_NAME $fastcgi_script_name; # Don't put it for PHP but keep it otherwise #fastcgi_param DOCUMENT_ROOT /var/hg; fastcgi_param PATH_INFO $path_info; # Super important or Python freaks out } } # End of the server directive

server { listen 83; #listen 192.168.1.1:8080;

server_name ubuntu;

location / { root /var/www/mercurial; index index.cgi; }

location ~ \.cgi($|/) {

# auth_basic "Restricted area"; # auth_basic_user_file /etc/nginx/htpasswd; #htpasswd must be created using Apache's htpasswd program include /etc/nginx/fastcgi.conf;

set $script $uri; set $path_info "";

if ($uri ~ "^(.+\.php)(/.+)") { set $script $1; set $path_info $2; }

#root /var/hg;

proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; fastcgi_pass unix:/var/run/nginx/fcgi.sock; #fastcgi_pass 127.0.0.1:10008; fastcgi_pass_header Authorization; fastcgi_intercept_errors off; fastcgi_param SCRIPT_FILENAME /var/www/mercurial$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; # Don't put it for PHP but keep it otherwise #fastcgi_param DOCUMENT_ROOT /var/hg; fastcgi_param PATH_INFO $path_info; # Super important or Python freaks out } } # End of the server directive } # End of the config file

----------------------------------------------------

And fastcgi.conf:

---------------------------------------------------- # /etc/nginx/fastcgi.conf fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx;

# Required otherwise the .cgi content is served as plain text fastcgi_param QUERY_STRING $query_string;

# Required for dealing with POST requests fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; 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; # PHP only, required if PHP was built with --enable-force-cgi-redirect #fastcgi_param REDIRECT_STATUS 200;

------------------------------------------------------------------------------------

Here is my mercurial apache configuration file:

------------------------------------------------------------------------------------ # receive requests on all interfaces, use IP:port instead NameVirtualHost *

# Following directives only apply to the * virtual host <VirtualHost *>

# Used for creating redirection URLs ServerName ubuntu

# The directory from which httpd will serve files DocumentRoot /var/www/mercurial

# Aplly directives only to the / directory and its subdirectories <Directory />

# Ressource to look for when client requests an index by specifying / # You don't need this rule it is useless # DirectoryIndex index.cgi

# treat .cgi files as CGI programs AddHandler cgi-script .cgi

# Follow symbolic links in that directory Options ExecCGI FollowSymLinks

# First Allow directives are evalutated then the Deny Order allow,deny

# All hosts are allowed access Allow from all

# AuthUserFile /etc/nginx/htpasswd # AuthName "Depot Mercurial" # AuthType Basic # <Limit POST PUT> # Require valid-user # </Limit>

# activate rewrite module RewriteEngine on

# Rewrite / to index.cgi # If you remove this rule, you need to type http://ubuntu/index.cgi in firefox # Pushing to http with: hg push http://ubuntu:90 still works # RewriteRule ^$ index.cgi [L]

# RewriteCond precedes a RewriteRule # You don't need the following rules everything still works # RewriteCond %{REQUEST_FILENAME} !-f # RewriteRule (.*) index.cgi/$1 [QSA,L] </Directory> </VirtualHost>

------------------------------------------------------------------------------------- I tried reducing it to its minimal unti mercurial doesn't work anymore.

How does it look like?

Again, using the exact same configuration files and different fastcgi servers, I have had different behaviors for mercurial. And apache+mercurial works perfectly.