Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
vasilisgogos
New Contributor III

FortiWEB full URL Rewriting

Hello Team,

I am trying to rewrite  https://exapmle.in.com to https://exapmle2.out.net (URL are fake).

I have tried HTTP header rewriting ( without success) and body rewriting 9 the URL was redirecting to the new URL, which is not our case).

We need to keep the traffic to Fortiweb and not redirect the traffic to the end URL.

Bello the config

 

config waf url-rewrite url-rewrite-rule

edit "ASK-AI-REWRITING"
set host-status enable
set host exapmle.in.com
config header-insert
end
config response-header-insert
end
config header-removal
end
config response-header-removal
end
set request-remove-duplicate-headers disable
config match-condition
edit 1
set reg-exp exapmle2.out.net
set HTTP-protocol https
next
end
next
end

config waf url-rewrite url-rewrite-rule
edit "ASK-AI-REWRITING-2"
set action http-response-header-rewrite
set location_replace $0exapmle.in.com$1
set location-status enable
config header-insert
end
config response-header-insert
end
config header-removal
end
config response-header-removal
end
set response-replace-existing-headers enable
config match-condition
edit 1
set object http-location
set reg-exp (.*)exapmle2.out.net(.*)
next
end
next
end

 

Attached the URL RULE.

The problem is that the end Application Server is not accepting Requests that done not have exapmle2.out.net in HTTP HEADER( body).

 

 

 

 

Senior Network Security Engineer
Senior Network Security Engineer
1 Solution
vasilisgogos
New Contributor III

Hello, 

We found the solution.

Request Action

1- Request action should match HTTP Host (whole URL- URL1))
2- Replacement URL  - select Host - the backend URL (URL2)

Response action

1- Match both HTTP location with syntax (/*)URL2(/*)

    and HTTP Host with syntax (.*)URL2(.*)

2- Replacement String: Location - URL1

3- HTTP header Insertion enabled with Replace existing header and syntax  $0URL1$1

4- HTTP Header Removal enabled (remove Duplicate Headers) 

 

Also, the backend service should match the frontend service (HTTPs-->HTTPs or HTTP-->HTTP) 

Senior Network Security Engineer

View solution in original post

Senior Network Security Engineer
12 REPLIES 12
AEK

The FWB config I provided doesn't do any redirection.

I suspect your back-end server is doing a redirection. I usually see such behavior, for example when back-end server uses an absolute link to itself.

E.g.: instead to redirecting to /login.html, it redirects to server.com/login.html.

Can you check?

AEK
AEK
vasilisgogos
New Contributor III

Hello, 

We found the solution.

Request Action

1- Request action should match HTTP Host (whole URL- URL1))
2- Replacement URL  - select Host - the backend URL (URL2)

Response action

1- Match both HTTP location with syntax (/*)URL2(/*)

    and HTTP Host with syntax (.*)URL2(.*)

2- Replacement String: Location - URL1

3- HTTP header Insertion enabled with Replace existing header and syntax  $0URL1$1

4- HTTP Header Removal enabled (remove Duplicate Headers) 

 

Also, the backend service should match the frontend service (HTTPs-->HTTPs or HTTP-->HTTP) 

Senior Network Security Engineer
Senior Network Security Engineer
filiaks1
Contributor II

Announcements
Check out our Community Chatter Blog! Click here to get involved
Labels
Top Kudoed Authors