Installing Wordpress on virtualhost

Salut @LayLow

https://ns8.debian.toto-dev.org/phpmyadmin/.

image

.

‘usagerwpbd’@‘%’ <====== ‘%’

Michel-André

2 Likes

Merci!

Is there a way to ‘solve’ the infamous ‘Mixed content’. issue with WP by means of htaccess, thus not via an extra WP module? Examples that I found on the net did not work for me yet, maybe because these examples are not ‘container’ aware?

Salut @LayLow

What do you mean by “Mixed content” ?

Michel-André

https and http. scripts are called over http and will not load due to enforced https. It seems to be a common problem, but I do not want to solve it at application level but at webserver level.

Salut @LayLow,

Replace https with http, but I do not know if that will do what you want.

How to change a WordPress URL step-by-step - IONOS CA.
Change WordPress site URL in the admin dashboard.
The most common and easiest way to change the WordPress URL is to enter it directly in the admin dashboard. To do this, navigate to “Settings” > “General” in the admin area. There you will find the input fields where you can change the WordPress site URL or the website URL.

Michel-André

Yes, that is the case and I did change it already by advise of @stephdl in an old thread (directly in db tables). But still the mixed content, scripts are pulled in via http and thus blocked. I am the only one? (Rocky Linux)

Salut @LayLow

I run Debian-12.

Is the port 443 blocked by something ?

I remember commenting all the long keys in wp-config.php.
I do not know if it is related.

To allow the reading of all the .htaccess files (AllowOverride ALL), I am more familiar with Apache in NS-7 than with Nginx in NS8.

There is a directive in the conf file to pass the header as is, with no change, from the requesting URL, but I cannot find it anymore :frowning: . @mrmarkuz should remember and know how to use it with Nginx.

Michel-André

2 Likes

I remember the mixed content issue in combination with reverse proxy. I’m going to test it asap…

3 Likes

Not really, https is working just fine, it is just that inner code of WP call (js)scripts via http and not via httpS. I have found some sample scripts for Nginx on htaccess, but none of them are working :frowning:

I guess I have been spoiled all those years by e-smith easy of use and module makers all that time :slight_smile:

Thanks!

I came across this, but I have no clue how to test this.


When using a reverse proxy with Nginx and WordPress, it is common to encounter mixed content issues. This occurs when the WordPress site is served over HTTPS, but some of the resources being loaded (such as images, scripts or stylesheets) are still being requested over HTTP.

To fix this issue, you can add the following lines to your Nginx configuration file:

proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

These lines will tell WordPress that it is being served over HTTPS, and will ensure that all resources are loaded using HTTPS as well.


And this is what I don’t want:

Additionally, you can use a plugin like Really Simple SSL to automatically detect and fix mixed content issues on your WordPress site. This plugin will also handle other common SSL-related issues, such as redirecting HTTP traffic to HTTPS.

These lines in wp-config.php worked for me to have no mixed content anymore. I found it here.

The example wordpress domain is wordpress.domain.tld

/* Add any custom values between this line and the "stop editing" line. */

define('.COOKIE_DOMAIN.', 'wordpress.domain.tld');
define('.SITECOOKIEPATH.', '.');

if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
        $_SERVER['REMOTE_ADDR'] = $list[0];
  }
define('WP_HOME', 'https://wordpress.domain.tld');
define('WP_SITEURL', 'https://wordpress.domain.tld');
$_SERVER['HTTP_HOST'] = 'wordpress.domain.tld';
$_SERVER['REMOTE_ADDR'] = 'https://wordpress.domain.tld';
$_SERVER['SERVER_ADDR'] = 'wordpress.domain.tld';

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
       $_SERVER['HTTPS']='on';

/* That's all, stop editing! Happy publishing. */

I requested a letsencrypt cert for the virtualhost but I think it’s not needed.

BTW, if I disable the letsencrypt cert for the virtualhost, it’s still there, even after reboot. How to revert to the self-signed cert? @stephdl

3 Likes

2 posts were split to a new topic: Disabling NS8 Nginx Virtualhost Lets Encrypt certificates is not possible

and works for me too! Bravo again… Thanks! I had 1 other issue but that had to do with a chrome plugin.

Thanks again.

2 Likes

add to your custom website a upgrade-insecure-requests to redirect transparently all content http to https. It seems specific to wordpress Content Security Policy | WordPress.org

since we are using Nginx as the engine, this is where we need to look forward when we want a fix.

cc @davidep

  • note1 : do you think we could bundle upgrade-insecure-requests as default inside webserver ?
  • note2 : we shared about to remove Nginx in the title of the module, but it is a clue where to search when we need to fix something

CSP: upgrade-insecure-requests - HTTP | MDN

9001 is your virtualhost ID, you can find it at

image

vim /home/webserver2/.config/state/conf.d/dyn-9001.custom

## avoid mixed content https/http for wordpress. good new internet explorer cannot works with it : https://caniuse.com/upgradeinsecurerequests
add_header Content-Security-Policy upgrade-insecure-requests;

then go to the virtualhost menu and save again to restart nginx and build again the configuration

writing a how to on how to install wordpress

5 Likes

:ok_hand: :pray:

2 Likes

Would it be an impertinent request to ask whether it would not be better to provide a container via the software center, consisting of a vhost with a selectable PHP version, database and WordPress?
I think that would also help to reduce the support volume here.

well this won’t be available one day I bet, but in fact what we could provide is a full container with mariadb bundled and the good expected version of PHP for wordpress, maybe this was what you were requested

bundle database and webserver I am not sure it is a good idea, except it will lower the use case of user@localhost that it won’t never work with two containers to user@% which means anyhost

cc @davidep

3 Likes

trying to write a full howto @capote and I would be pleased to know if it could explain for non technical all steps and tricks

2 Likes

I will test it. Thank you.

1 Like