For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

chrispr_172493's avatar
chrispr_172493
Icon for Nimbostratus rankNimbostratus
Aug 05, 2015

how to publish wordpress subsite from root / - URI Masking

Hi everyone,

 

I have been tasked to publish a wordpress site (myapp)

 

from the root of the domain

 

http://myapp.mysite.com.

 

however it has been installed myapp.mysite.com/wordpress/

 

yes, the development life cycle was.

 

1) lets do a 'test', 2) works great 3) just make this 'test' the PROD thanks,

 

I am confident that it would be possible to do f5 magic to serve

 

the subsite at http://myapp.mhsite.com/

 

aka URI masking for the wordpress instance which has been installed under /wordpress

 

has anyone done this already ?

 

there is already another app published on same server,

 

from the root under different URL (otherapp.mysite.com)

 

www server IP (node) = 1.2.3.4

 

DNS myapp.mysite.com. resolves to IP 1.2.3.4 ( to be published new VS y.y.y.y )

 

DNS otherapp.mysite.com resolves to IP 1.2.3.4 ( published under existing VS z.z.z.z )

 

server is IIS 7.5, perhaps it's possible on the IIS, with referrer or similar, I don't have direct access to server and enjoy the challenge/pain.

 

I've been crawling through devcentral today and the closest i got to masking the obscure /wordpress URI

 

was to replace the /wordpress with /myapp.

 

this looks more meaningful but is still suboptimal.

 

any assistance would be very welcome.

 

first time poster,

 

Chris

 

3 Replies

  • thank you Kevin and Patrik, makes sense, I'll persist with it. thus far when i peel back the /wordpress i get otherapp.mysite.com. I'm on the right track thou... thanks

     

  • So if I understand your question, your app is accessible with the /wordpress URI prefix, but you want it externally accessible as simple "/". In order to make this work you have to do a few things:

    1. You have to make sure that all response content (HTTP headers and payload) with this URI are mapped from /wordpress to /

    2. You have to rewrite the URI prefix from / to /wordpress[HTTP::uri] on each incoming request.

    So let's take a look at what that iRule might look like:

    when HTTP_REQUEST {
         don't let the server compress responses
        HTTP::header remove Accept-Encoding
    
         disable STREAM for requests
        STREAM::disable
    
         rewrite URI if it doesn't start with /test
        if { not ( [string tolower [HTTP::uri]] starts_with "/wordpress" ) } {
            HTTP::uri "/wordpress[HTTP::uri]"
        } 
    }
    when HTTP_RESPONSE {
         catch and replace redirect location headers
        if { [HTTP::header exists Location] } {
            HTTP::header replace Location [string map -nocase {"/wordpress" "/"} [HTTP::header Location]]
        }
    
         enable STREAM to replace payload URI content
        STREAM::expression {@/wordpress@@}
        STREAM::enable
    }
    

    This is a simple example, so you may have to tweak a little to get it just right, but hopefully it makes sense. You can also accomplish most/all of this with URI-translation rewrite profile if you're running a newer version of BIG-IP.

  • Have to ask, can't you just move the wordpress application to the root instead? There are multiple articles out there on how to do this.

    Here's one:

    https://wordpress.org/support/topic/moving-wordpress-from-subfolder-to-root-folder

    That said, you CAN rewrite the incoming requests to append "/wordpress" with an iRule:

    when HTTP_REQUEST {
    
        set uri [string tolower [HTTP::uri]]
        set host [string tolower [HTTP::host]]
    
        Make sure that the site accessed is myapp.mhsite.com 
        if { $host -eq "myapp.mhsite.com" } {
    
            Add a the wordpress folder to the request for the backend calls if the wordpress path is not there already
            if { ! $uri starts_with "/wordpress" } { 
                HTTP::uri "/wordpress$uri"
            }
        }
    
    }
    

    But this would not handle the outgoing response containing links to /wordpress. For that you'd need to enable a stream profile which replaces /wordpress with "":

    https://support.f5.com/kb/en-us/solutions/public/8000/100/sol8115.html

    Hope I understood your question properly. 🙂

    /Patrik