Forum Discussion
Virtual server with two different web servers
I have a virtual server that needs to have two different web servers behind it, so that I can present it via the internet. The reasoning for this is server1, redirects to server2 two for authentication, then after authenticating it redirects back to server1, where it stays for all other functions.
I tried using this irule below, but it does not seem to be working. It is forwarded to the other site, but using the internal name of the site, so it times out as it is not available under that name on the internet.
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "server1.domain.com" { pool server1_test_pool } "server2.domain.com" { pool server2_test2_pool } } }
15 Replies
- Michael_Jenkins
Cirrostratus
Is your web server expecting soemthing different than server2.domain.com? Is it expecting server1.domain.com as well to access the website?
- Keith_Fox_15580
Nimbostratus
No, it is not. The process is as follows: Server1 receives initial web request, upon this request it forwards to server2 for authentication, then forwards back to Server1, where the rest of the web traffic will be taken place.
I am stuck at where server1 directs to server2, it is using an internal address, which externally is not resolvable, so I get a server cannot be found error. I need all this address translation to happen behind the virtual server, not a redirect to a server2 which is not accessible via the internet with it's name.
- What_Lies_Bene1
Cirrostratus
Why not just use two Virtual Servers. Change DNS so server1. and server2. resolve to different IPs (and thus different Virtual Servers) and configure your F5 as appropriate.
If you want to stick to the iRule I would suggest you also turn on OneConnect. You could use a stream profile to rewrite the internal name as required but I'd say it would be better to fix this at the server.
- Keith_Fox_15580
Nimbostratus
I wish using two virtual servers would work, but they have hard set in the web program to redirect to the internal name, so it's not possible, and the internal domain is not something we own, so not route-able outsie of our LAN.
- What_Lies_Bene1
Cirrostratus
Understood, not unusual. So, you'll need a Stream Profile and iRule to rewrite the responses and replace any instance of the internal name with a suitable external one. See here for a simple example: https://devcentral.f5.com/wiki/iRules.STREAM__enable.ashx and further details.
- Keith_Fox_15580
Nimbostratus
Ok, I am new to the F5, so you are saying I will still need to external Virtual servers to perform this operation, or just one, with the stream?
- What_Lies_Bene1
Cirrostratus
It's your choice. You can stick with 1, have DNS provide the same IP for both domain names and use the iRule to select the correct server. Or have a second VS, second pool, different IP in DNS.
By the way, when you change the name for the second server in responses, and the client comes back in with a request, will the second server accept it or does it expect that internal name to have been used?
- Keith_Fox_15580
Nimbostratus
I believe it is going to expect the internal name to redirect it back to the other site.
- Keith_Fox_15580
Nimbostratus
I have setup an irule, and blank stream profile, but it is not changing the URL using the irule I have below, I am sure it is something I am doing wrong.
when HTTP_REQUEST {
Explicitly disable the stream profile for each request so it doesn't stay
enabled for subsequent HTTP requests on the same TCP connection.
STREAM::disable
}
when HTTP_RESPONSE {
Apply stream profile against text responses from the application
if { [HTTP::header value Content-Type] contains "text" }{
STREAM::expression {@insideserver.domain.com@outsidserver.domain.com@} Enable the stream profile STREAM::enable}
}
- Michael_Jenkins
Cirrostratus
Can you try to log the request uri and response for me and paste what you get. Something like this...
when HTTP_REQUEST { log local0. "Request URL: "[HTTP::host][HTTP::uri]" } when HTTP_RESPONSE { log local0. " Response: Status=[HTTP::status] | Location=[HTTP::header value Location]" }Otherwise, it could be that you're getting a 302 or 301 response to redirect to the other page. At that point you would rewrite the Location header. If the link to the other internal host is in the response body, you may want to check out trying to remove the "Accept-Encoding" header (see STREAM::expression wiki page or one of the notes on [SOL8115(https://support.f5.com/kb/en-us/solutions/public/8000/100/sol8115.html))
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com