• Hi!

    I have WP 5.3.2 running in a container. Its behind my apache server and almost sorta working.

    Main apache server is reverse proxying for my wp/apache/container.

    I can get regular http to work to access my wp site. Almost. However, over http the hidden container URL blahblah:8100 appears in the html code.

    When I try to access the site via ssl, via apache reverse proxy, the content comes through but links, css, images, etc, all show non-https URLs and thus my browser chokes on it.

    For both http and https, shouldnt the local URLs be hidden and everything refer to the external URL? How do I make that so?

    What settings should I use for WordPress Address and Site-Address URLs?

    I’m using http to communicate between apache reverse proxy and the docker/wp container. When I try to do this via https, I get permission denied.

    Any suggestions, writeups, etc. on how to make this work?

    Thanks,

    Bobby

    • This topic was modified 6 years, 5 months ago by rdkwp.
    • This topic was modified 6 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Installing WordPress topic
Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    When I try to access the site via ssl, via apache reverse proxy, the content comes through but links, css, images, etc, all show non-https URLs and thus my browser chokes on it.

    The browser is choking because the content for URLs, css, images, etc. being sent back don’t make sense. Can you provide an example of the URLs sent back to the browser?

    You could change the site URL/WordPress Address but you also have an option on the reverse proxy to modify the content there and “fix” the URLs.

    Thread Starter rdkwp

    (@rdkwp)

    Hi!

    Thanks for your reply. My reverse proxy is for the path /lab That is, I want my apache reverse proxy to map anything /lab/ to go to the WP/container on port 8100.

    My wordpress is running on port 8100 in a container. I’ve left the WP Install Address URL unchanged — XXX:8100 I changed site address to XXX/lab

    What I get back is some of the WP content properly puts XXX/lab but images, CSS, icons, etc all say XXX:8100 and not XXX/lab

    Make sense? I can provide more specific URLs if you need.

    Thank you,

    Bobby

    Thread Starter rdkwp

    (@rdkwp)

    Hi!

    When I changed the WP address and Site address URLs to be XXX/lab it broke my access and I had to go into the database to change them back.

    Kinda surprised that there is no good cheat sheet for getting my setup to work.

    When I get it to work, I’m happy to submit something.

    Thanks,

    Bobby

    Thread Starter rdkwp

    (@rdkwp)

    Hi!

    I’m almost there. I set the site address and install address URLs to be my xxx/lab URL. Its almost working now.

    Now, I’m getting the dreaded exceeded limit redirect error in the wordpress apache log. I think I need to tweek my wordpress .htaccess file.

    I’ve been searching for a while now. Any pointers on how to fix this? I can see the main page of my wordpress site but any links to it have correct URL but they generate the internal-server error. Ugh.

    Bobby

    Thread Starter rdkwp

    (@rdkwp)

    Hi!

    I managed to get everything working through combo of edit to wp-config.php, setting site-url and address-url, plus placing a link in the install directory pointing the subdir to install dir.

    Bobby

    Hi rdkwp

    I have the same problem, could you give me the example of wp-config.php configuration please.

    Pura vida!

    Thread Starter rdkwp

    (@rdkwp)

    Hi!

    Here are my apache settings:

    <Location /lab>
    RequestHeader set X-Forwarded-Proto “https”
    RequestHeader set X-Forwarded-Port “443”
    ProxyPass http://XXX:8100
    ProxyPassReverse http://XXX:8100
    Order allow,deny
    Allow from all
    </Location>

    In wp-config.php:

    define(‘WP_SITE_URL’,’https://xxx/lab&#8217;);
    define(‘WP_SITEURL’,’https://xxx/lab&#8217;);
    define(‘WP_HOME’,’https://xxx/lab&#8217;);

    In .htaccess:

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

    And finally in /var/www/html, I added a softlink lab that points to .
    ln -s lab .

    Hope that helps. Let me know if you have more specific questions. Feel free to email me. I’ll make sure my profile has my email address.

    Bobby

    Hi Bobby, I am facing the same issue when setting up SSL secured wordpress in a docker container.
    OS: CentOS 7 in both main host and container. PHP 7.3

    In main apache host:

    Added below Proxypass entries in sub.example.com’s port 80 and 443 virtual hosts.

    <Location /blog>
    RequestHeader set X-Forwarded-Proto “https”
    RequestHeader set X-Forwarded-Port “443”
    ProxyPass http://10.X.X.X:8085
    ProxyPassReverse http://10.X.X.X:8085
    Order allow,deny
    Allow from all
    </Location>

    inside container, wordpress is installed in /var/www/html.

    .htaccess below.

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

    wp-config.php below

    define(‘WP_HOME’,’https://sub.example.com/blog&#8217;);
    define(‘WP_SITEURL’,’https://sub.example.com/blog&#8217;);

    Still when I try to access https://sub.example.com/blog/, it shows the contents with formatting completely lost. http://sub.example.com/blog/ loads fine.

    Both https://sub.example.com/blog/wp-admin and http://sub.example.com/blog/wp-admin gives 404 errors. Can you please suggest if anything I missed

    Thread Starter rdkwp

    (@rdkwp)

    Hi!

    In /var/www/html, I added a soft link. For you, I would try ln -s blog .

    Also, in my wp-config.php file, I added a def for WP_SITE_URL but not sure if it matters.

    Finally, in wp-config.php, I also added:

    $_SERVER[‘REQUEST_URI’] = ‘/lab’ . $_SERVER[‘REQUEST_URI’];

    Hope this helps,

    Bobby

    Thank you for the response Bobby. Unfortunately I am still not able to make it work. When I put pure html file instead of wordpress, proxypass is working fine.

    When I create symlink with the command you mentioned, output is as follows.

    [root@host html]# pwd
    /var/www/html
    [root@host html]# ls -al blog
    lrwxrwxrwx 1 root root 4 May 19 01:51 blog -> blog
    [root@host html]#

    Thread Starter rdkwp

    (@rdkwp)

    Hi!

    Ahh, I think I ran into this as well.

    I originally put everything in subdirectory “lab” and it was still broken.

    I moved everything into main directory and then linked lab to main directory.

    In my main root install dir, I have:

    index.php
    wp-config.php
    readme.html
    lab soft-link to .
    all the other php files.

    Once I did this, it started working.

    ln -s lab .

    Bobby
    % ls -l lab
    lrwxrwxrwx 1 root root 1 Feb 4 16:16 lab -> .

    I think the symlink command should be “ln -s . blog” (not ln -s blog . )

    [root@02352f099824 html]# ls -al blog
    lrwxrwxrwx 1 root root 1 May 19 03:28 blog -> .
    [root@02352f099824 html]#

    Also I added one more entry in wp-config.php.

    if (strpos($_SERVER[‘HTTP_X_FORWARDED_PROTO’], ‘https’) !== false)
    $_SERVER[‘HTTPS’]=’on’;

    After adding this entry above the define(‘WP_HOME’, it started working.

    Note: define(‘WP_SITE_URL’,’https://sub.example.com/blog&#8217;) is commented. As you pointed out, this line is not required, it seems.

    Formatting of https://sub.example.com/blog also working fine now. Hopefully there are no surprise issues.

    Thank you so much Bobby for your help.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘WP behind apache reverse proxy’ is closed to new replies.