Welcome! Log In Create A New Profile

Advanced

Major Manipulate Doubts (couldn't find anywhere)

Posted by brb 
brb
Major Manipulate Doubts (couldn't find anywhere)
April 27, 2017 02:50PM
Hello, i have the following specifc doubts:

1st: it`s possible to concat variables? i mean i want to do an if statement like this:
if ($host$request_uri ~ ^https?:\/{2}([^w]{3})(.*)\/$) {
set $redirect_option 3
}

But so far i wasn`t able to get the full url (domain + uri), only one or other and this is crippling me :/

2nd: Trying to find out a solution (assuming i can`t have the full url to match with regex), i`ve tried something like this:


XYZ are conditions ommited here

set $redirect_condition 0;
if ($force_ssl = XYZ) {
set $redirect_condition 1;
}

if ($request_uri ~ ^/healthcheck(.*)$) {
set $redirect_condition 0;
}

if ($request_uri ~ ^/(.*)/$) {
set $redirect_condition 2;
}

if ($host ~ ^https?:\/\/[^w](.*)) {
set $redirect_condition "${redirect_condition}3";
}

try_files $uri/index.html $uri @unicorn;
location @unicorn {
if ($http_x_forwarded_proto = "https") {
add_header Strict-Transport-Security "max-age=60; includeSubDomains";
}

if ($redirect_condition = 23) {
rewrite ^/(.*)/$ https://www.anydomain.com/$1 permanent;
}


if ($redirect_condition = 1) {
rewrite ^ https://$host$request_uri? permanent;
}

if ($redirect_condition = 2) {
rewrite ^/(.*)/$ https://$host/$1 permanent;
}



Any suggestion to make it works? TY
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 206
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready