proper way to redirect from http to https w/query string notifier

Edho Arief me at myconan.net
Tue Mar 24 17:50:29 UTC 2015


On Wed, Mar 25, 2015 at 2:32 AM, Francis Daly <francis at daoine.org> wrote:
> On Tue, Mar 24, 2015 at 11:33:41AM -0400, Jonathan Vanasco wrote:
>
> Hi there,
>
>>                       if ($query_string){
>>                               return 301 https://$host$request_uri&source=server1 ;
>>                       }
>>                       return 301 https://$host$request_uri?source=server1 ;
>>
>> I'm just wondering if there is a more appropriate way
>
> If your backend will accept /request?source=server1 and
> /request?&source=server1 as being equivalent, then you could use the
> $is_args variable and just always
>
>   return 301 https://$host$request_uri$is_args&source=server1;
>

that looks wrong since when there's argument:

$request_uri: /path/name?arg=uments
$is_args: ?

whereas when there's no argument:

$request_uri: /path/name
$is_args: <blank>

(now imagine when your return is used)
.

One possible solution would be just `$host$uri?source=server1&$args`

<note: untested>



More information about the nginx mailing list