WordPress.org

Ready to get started?Download WordPress

Forums

Problem with WordPress sitting on a backend server. (3 posts)

  1. Mineria
    Member
    Posted 8 months ago #

    Hi, I have a WordPress server sitting on an internal domain which I want to be available via an external domain name that I use on another server.
    Which means, I want http://my.backend.domain.com to be available via http://mylivedomain.net/blog

    I also added an A-record for my.backend.domain.com on the responsible DNS server for that domain.
    I did set my WordPress URL’s like this:

    WordPress Address (URL) http://my.backend.domain.com
    Site Address (URL) http://mylivedomain.net/blog
    Permalink Settings is set to “Post name” and the following .htaccess file sits in the document root.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    And my Apache VirtualHost file named “my.backend.domain.com” looks like this:

    <VirtualHost *:80>
            ServerAdmin hostmaster@livedomain.net
            ServerName  my.backend.domain.com
            # Directory Root
            DocumentRoot /var/www/mysite
            <Directory />
                    Options -Indexes -Includes -ExecCGI FollowSymLinks MultiViews
                    AllowOverride All
            </Directory>
            <Directory /var/www/mysite/>
                    Options -Indexes -Includes -ExecCGI FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
            </Directory>
            # Logfiles
            ErrorLog  /var/log/apache2/mysites_error.log
            # Possible values include: debug, info, notice, warn, error, crit,alert, emerg
            LogLevel debug
            CustomLog /var/log/apache2/mysites_access.log combined
    </VirtualHost>

    I have a tested and working netscaler rule that points all http://mylivedomain.net/blog* requests to http://my.backend.domain.com*
    Note, the firewall will not allow external access to the internal domain, so everything client side needs possible requests presented via mylivedomain.net/blog.

    With PC’s on my internal networks, I have no problems to get the wordpress blog presented, works just perfect.
    With PC’s on external networks, I get the main site (index.php) presented, but only the text, all images, css stylesheets and js scripts fail.

    What more do I need to make this work for external clients?

    I also found that typing permalinks doesn’t work from the external connected PC’s.
    As example, http://mylivedomain.net/blog/hello-world/ doesn’t work since the GET looks for //hello-world/ instead of /hello-world/ like it does when browsing from the internal PC’s.

    I have tried apache mod_proxy to see if that could solve it, but didn’t help either.
    Enabled proxy and proxy_http and used following in the backend domains VirtualHost file:

    ProxyPass /blog/ http://my.backend.domain.com/
    ProxyPassReverse /blog/ http://my.backend.domain.com/

    Anyone got a setup like the one I try to archive that can see what I’m missing to make it work?

  2. Mineria
    Member
    Posted 8 months ago #

    Worked a bit more on it and got following now.

    Virtual host file:

    ServerName   http://mylivedomain.net/blog
    ServerAlias  my.backend.domain.com

    When I ran WP install for the first time it still went back to the backend url, I switched that:

    WordPress Address (URL) http://mylivedomain.net/blog
    Site Address (URL) http://mylivedomain.net/blog

    And also edited other references in the DB.

    The site loads scripts and images on index.php now, but still goes back to my.backend.domain.com when I click links.

    Tried then to force the WP and SITE URL's via wp-config, it still tries to use the backend url.

    Is there some way to force it to use the live url always?

    I have two other WP installations with their own root folders and databases that need to run under the same conditions from the same backend server, so I can not have anything globally on the server, it needs to be done directly on each WordPress installation and the Apache VirtualHost that belongs to it.

  3. Mineria
    Member
    Posted 8 months ago #

    A friend from cbox.dk had the solution for me, so added this to the themes funxtions.php:
    remove_filter('template_redirect', 'redirect_canonical');
    And it works!

Reply

You must log in to post.

About this Topic