Skip to main content
mohaja
New Member
October 16, 2018
Question

Redirect or rewrite: Virtual directory to port

Hi,

I have a server running 2 service at different port :

1.2.3.4:5601

1.2.3.4:3000

 

and I want to serve those service by using directory/folder at FortiWeb. eg

public.mydomain.com/abc

public.mydomain.com/xyz

will go to 1.2.3.4:5601  &  1.2.3.4:3000 respectively.

 

How can i get it to work ? Did try using 'HTTP Content Rounting' but failed. Still new to this.

 

Version : FortiWeb-1000D 5.54

 

Thank you.

 

    3 replies

    ede_pfau
    SuperUser
    SuperUser
    October 16, 2018

    Content routing is the way to go. Each target (server IP + destination port) is a 'real server', so you need two. It's pretty straightforward.

    If your setup fails, post what you've done.

    mohaja
    mohajaAuthor
    New Member
    October 17, 2018

    Thats what i thought. My steps as follows

    1) Create 2 'Server Pool' with "Type: reverse proxy", "Single Server. One is 1.2.3.4:5601 and another 1.2.3.4:3000. So there is server pool 'abc' and 'xyz'

    2) Create 2 'HTTP Content Routing' for each 'Server Pool' from (1).

    - One with 'Match Object' -> 'HTTP URL' -> 'Match contains' -> abc

    - One with 'Match Object' -> 'HTTP URL' -> 'Match contains' -> xyz

    3) Create 1 Policy -> 'Deployment Mode' : 'HTTP Content Routing'. Then add both routing from (2). Just that, no other feature enable (eg http to https)

     

    Both giving 404. I think it is cause by the folder public.mydomain.com/abc because if i set one of the routing policy as 'Default' and open just public.mydomain.com , it would go to that specific service either :3000 or :5601

     

    I think this would involve URL Rewriting. Suggestion please.

     

    Thanks

    ede_pfau
    SuperUser
    SuperUser
    October 17, 2018

    In CR, it should match 2 criteria:

    1- the HOST field e.g. public.mydomain.com

    2- the URL e.g. "/abc"

     

    That should be all it takes.

    Your server should accept the URLs, like "public.mydomain.com/abc".

    Try to debug on the server: does it see the request? on which port? does it handle it, or send an error page instead? That would give you an idea which instance rejects the request, the FWB or the web server.

    Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
    Thought Leadership. Security Summit. Thursday, October 8th. Disney's Grand Californian Hotel & SPA, Anaheim, CA.
    Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT