nginx Digest, Vol 62, Issue 43

Julio Cesar dos Santos cesarshlbrn at hotmail.com
Mon Dec 29 20:12:03 UTC 2014


Gtx

-mensag. original-
Assunto: nginx Digest, Vol 62, Issue 43
De: nginx-request at nginx.org
Data: 29/12/2014 14:48

Send nginx mailing list submissions to
	nginx at nginx.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://mailman.nginx.org/mailman/listinfo/nginx
or, via email, send a message with subject or body 'help' to
	nginx-request at nginx.org

You can reach the person managing the list at
	nginx-owner at nginx.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of nginx digest..."


Today's Topics:

   1. Re: Having multiple Symfony2 apps on same domain (B.R.)
   2. Re: nginx removes double slashes (Maxim Dounin)
   3. Header SSL client certificate (Equipe R&S Netplus)
   4. Re: How Nginx behaves with "proxy_bind" and DNS resolver with
      non matching ip versions between bind ip and resolved ip?
      (Maxim Dounin)


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

Message: 1
Date: Mon, 29 Dec 2014 16:47:51 +0100
From: "B.R." <reallfqq-nginx at yahoo.fr>
To: Nginx ML <nginx at nginx.org>
Subject: Re: Having multiple Symfony2 apps on same domain
Message-ID:
 <CALqce=1ZzBf5MbLP9+57sxvkfFHQHH=6_XN-SXAzpTA9gpjZqA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Glad I helped ! :o)
---
*B. R.*

On Mon, Dec 29, 2014 at 3:52 PM, Naji Astier <naji.demolitionman at gmail.com>
wrote:

>  Thanks you for your answer, you helped me to make it working. ;)
> This is my final configuration :
>
> server {	listen   80;
> 	server_name mydomain;
> 	root /server/www; 	location @rewriteMainApp {		rewrite ^(.*)$ /app.php/$1 last;	} 	location @rewriteOtherApp1 {		rewrite ^(.*)$ /subdir1/app.php/$1 last;	}	location /subdir1 {		alias /server/www/other-app1/web;		index app.php;		set $subfolder "other-app1/web";		try_files $uri @rewriteOtherApp1;	}	location / {		root /server/www/main-app/web;		index app.php;		set $subfolder "main-app/web"; 	try_files $uri @rewriteMainApp;	}	# PROD	location ~ /app\.php(/|$) {	 fastcgi_pass unix:/var/run/php5-fpm.sock;		include fastcgi_params;	 fastcgi_param SCRIPT_FILENAME $document_root/$subfolder/app.php;	}}
>
>
>
> Le 29/12/2014 00:03, B.R. a ?crit :
>
>  You are using the same named location as the fallback of the try_files
> directive, although you are dealing with three different paths.
>
>  Why do not you use one fallback named location per app location, each
> rewriting to the correct path?
>   ---
> *B. R.*
>
> On Sun, Dec 28, 2014 at 10:16 PM, Naji Astier <
> naji.demolitionman at gmail.com> wrote:
>
>> Le 28/12/2014 20:30, Steve Holdoway a ?crit :
>>
>>  On Sat, 2014-12-27 at 05:52 -0500, Claros wrote:
>>>
>>>> Hello everybody !
>>>>
>>>> I just switched from Apache2 to Nginx and I met some issues having the
>>>> same
>>>> configuration. What I want to do is having multiple Symfony2 apps on the
>>>> same domain name. Each app will have a subdirectory and a main app will
>>>> be
>>>> on the domain name itself. For instance :
>>>> http://mydomain/               -> main app
>>>> http://mydomain/subdir1   -> another app
>>>> http://mydomain/subdir2   -> yet another app
>>>> One of Symfony2 feature is to have only three php files to be executed,
>>>> and
>>>> all the URL are rewritten to those files. You can found basic
>>>> configuration
>>>> for Symfony2 at this address if you need more information :
>>>> http://wiki.nginx.org/Symfony
>>>> Now after many hours of configuration, with the help of debug logs, I
>>>> almost
>>>> did it. This is my current configuration :
>>>>
>>>> server {
>>>>      listen   80;
>>>>      server_name mydomain;
>>>>      root /server/www/main-app/web;
>>>>
>>>>      location @rewriteapp {
>>>>          rewrite ^(.*)$ /app.php/$1 last;
>>>>      }
>>>>
>>>>      location /subdir1/ {
>>>>          # alias /server/www/other-app1/web;
>>>>          set $root "/server/www/other-app1/web";
>>>>          # try to serve file directly, fallback to app.php
>>>>          try_files $uri @rewriteapp;
>>>>      }
>>>>
>>>>      location / {
>>>>          index app.php;
>>>>          set $root "/server/www/main-app/web";
>>>>          # try to serve file directly, fallback to app.php
>>>>          try_files $uri @rewriteapp;
>>>>      }
>>>>
>>>>      # PROD
>>>>      location ~ ^/app\.php(/|$) {
>>>>          fastcgi_pass unix:/var/run/php5-fpm.sock;
>>>>          fastcgi_split_path_info ^(.+\.php)(/.*)$;
>>>>
>>>>          include fastcgi_params;
>>>>          fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
>>>>          fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>>>>          fastcgi_param PATH_INFO $fastcgi_path_info;
>>>>      }
>>>> }
>>>>
>>>> Why did I create a variable "$root" ? Because when I was using the root
>>>> (or
>>>> alias) directive in a location block and the variable $document_root, I
>>>> found out that this variable has as final value (in the location
>>>> app.php)
>>>> the first root directive in the server or the default root location.
>>>> With this configuration, it almost work. The main app works and the
>>>> subdirectories are correctly sent to their directory. The last problem
>>>> is
>>>> that the URI processed by the file app.php also contains the
>>>> subdirectory in
>>>> it, so the others apps send 404 for all the URL. I tried to fix that by
>>>> changing "REQUEST_URI" parameter, but with that the app.php generate
>>>> wrong
>>>> URL without the subdirectory.
>>>>
>>>> So is their a way to achieve this configuration ? Thanks you !
>>>>
>>>> Posted at Nginx Forum:
>>>> http://forum.nginx.org/read.php?2,255806,255806#msg-255806
>>>>
>>> Try using a map to set the $root...
>>>
>>> Steve
>>>
>>>   Ok I did not know the map system, it is interesting. But it is only
>> simplifying my configuration, not solving the problem.
>>
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
>
> _______________________________________________
> nginx mailing listnginx at nginx.orghttp://mailman.nginx.org/mailman/listinfo/nginx
>
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20141229/e6f01b2c/attachment-0001.html>

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

Message: 2
Date: Mon, 29 Dec 2014 19:00:28 +0300
From: Maxim Dounin <mdounin at mdounin.ru>
To: nginx at nginx.org
Subject: Re: nginx removes double slashes
Message-ID: <20141229160028.GA3656 at mdounin.ru>
Content-Type: text/plain; charset=us-ascii

Hello!

On Mon, Dec 29, 2014 at 01:04:06PM +0200, Gregory Edigarov wrote:

> Hello everybody,
> 
> perhaps I am doing something wrong:
> 
>         location /njs/ {
>                 rewrite /njs/(.*)$ /$1 break;
>                 proxy_redirect off;
>                 proxy_set_header Host $http_host;
>                 proxy_set_header X-Real-IP $remote_addr;
>                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>                 proxy_set_header X-Forwarded-Proto $scheme;
>                 proxy_pass http://localhost:4006;
> 
>         }
> calling this
> http://[hostname]/facebook/bitly/http%3A%2F%2F[hostname]%2Fbeth-buczynski%2Fdiy-ways-to-stay-warm-in-winter%2F
> 
> and I definitely see that to my application it comes like:
> http:/[hostname]/beth-buczynski/diy-ways-to-stay-warm-in-winter/
> note the single '/', when I need '//'
> 
> Is there any way to handle it?

http://nginx.org/r/merge_slashes

-- 
Maxim Dounin
http://nginx.org/



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

Message: 3
Date: Mon, 29 Dec 2014 17:26:51 +0100
From: "Equipe R&S Netplus" <netplus.root at gmail.com>
To: nginx at nginx.org
Subject: Header SSL client certificate
Message-ID:
 <CAGeXBwM=u5RQ_iR64Hhe4qd8j0zULvzqrRs1Svuv1nLhtYmUow at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello,

I use nginx as a reverse-proxy.
I would like to set a header, more precisely a header that contain the SSL
client certificate.
However, the variable '$ssl_client_cert' add some character that I don't
want (like tab characters)

<<
proxy_set_header        X-SSL-CLI-CERT       $ssl_client_cert;
>>

I test with '$ssl_client_raw_cert', but the webserver in backend (here
apache) doesn't understand the certificate and return this :

<<
request failed: error reading the headers
>>

I see a previous post mentionning a workarount with 'map' (
http://forum.nginx.org/read.php?2,236546,236546) :

<<
map $ssl_client_raw_cert $a {
"~^(-.*-\n)(?<1st>[^\n]+)\n((?<b>[^\n]+)\n)?((?<c>[^\n]+)\n)?((?<d>[^\n]+)\n)?((?<e>[^\n]+)\n)?((?<f>[^\n]+)\n)?((?<g>[^\n]+)\n)?((?<h>[^\n]+)\n)?((?<i>[^\n]+)\n)?((?<j>[^\n]+)\n)?((?<k>[^\n]+)\n)?((?<l>[^\n]+)\n)?((?<m>[^\n]+)\n)?((?<n>[^\n]+)\n)?((?<o>[^\n]+)\n)?((?<p>[^\n]+)\n)?((?<q>[^\n]+)\n)?((?<r>[^\n]+)\n)?((?<s>[^\n]+)\n)?((?<t>[^\n]+)\n)?((?<v>[^\n]+)\n)?((?<u>[^\n]+)\n)?((?<w>[^\n]+)\n)?((?<x>[^\n]+)\n)?((?<y>[^\n]+)\n)?((?<z>[^\n]+)\n)?(-.*-)$"
$1st;
}
>>

But in debug log file of nginx, I have an error :

<<
[alert] 19820#0: *21 pcre_exec() failed: -8 on "
...
CERTIFICATE CONTENT
...
" using "^(-.*-
)(?<1st>[^
...
>>

I'm using nginx version 1.6.2, do you know another workaround please ?

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20141229/80be1827/attachment-0001.html>

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

Message: 4
Date: Mon, 29 Dec 2014 19:48:44 +0300
From: Maxim Dounin <mdounin at mdounin.ru>
To: nginx at nginx.org
Subject: Re: How Nginx behaves with "proxy_bind" and DNS resolver with
	non matching ip versions between bind ip and resolved ip?
Message-ID: <20141229164844.GD3656 at mdounin.ru>
Content-Type: text/plain; charset=us-ascii

Hello!

On Mon, Dec 29, 2014 at 02:36:55AM -0500, shmulik wrote:

> Hello,
> I'm working with the proxy module, and with a dns resolver configured. The
> traffic i'm using is both ipv4 and ipv6.
> 
> I'm trying to understand Nginx behavior when using "proxy_bind" directive
> and when the resolver returns both ipv4 and ipv6 addresses.
> 
> In particular i'd like to understand what happens when:
> 
> 1. "proxy_bind" binds to an ipv6 address, and the resolver returns only ipv4
> addresses (and the other way around - binding to ipv4, resolving only to
> ipv6).
> 
> 2. "proxy_bind" binds to an ipv6 address, the resolver returns both ipv4 and
> ipv6 addresses, but the first attempted ip address is an ipv4 address (and
> the other way around - binding to ipv4, first attempted is ipv6).
> 
> Can you please shed some light on this?

In either case nginx will call bind() syscall with the address 
provided in the proxy_bind directive.  If address family doesn't 
match one used in the connection, this is expected to result in an 
error.  The error itself will be logged into error log, and 500 
(Internal Server Error) will be returned to the client.

-- 
Maxim Dounin
http://nginx.org/



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

_______________________________________________
nginx mailing list
nginx at nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

End of nginx Digest, Vol 62, Issue 43
*************************************



More information about the nginx mailing list