• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx

  • We are developing a new feature in Plesk that will help you promote your websites or business on social media. We want to conduct a one-hour online UX test to present the prototype and collect feedback. If you are interested in the feature, please book a meeting via this link.
    Thank you in advance!
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Install Varnish on a CentOS7 with plesk obsidian and nginx

rplana

New Pleskian
I want to install varnish on a new server to work with wordpress, but the server has plesk and it works with nginx on port 80. If I'm not wrong I need to move the nginx port to 8080 (for example) and set varnish to 80 (apache also works in 7080). But this is not working at all, when I have apache, nginx and varnish active, nothing happens it still uses nginx on port 80 and if I reconfigure plesk with the command it reverts the changes I made to nginx and set port 80 as the default again, and it gives an error because varnish is already using port 80.

There's some way to fix it? Someway for plesk to use port 8080 to nginx by default or another way to use varnish with plesk without change this configuration?
 
You can use varnish in a docker. Then set the Proxy Rules via subscription

I saw that method too, but I will have more than one website on the server and I'm not sure if I can create a docker with varnish for every website or the number is limited.
And I also saw a lot of diferents configurations on docker varnish configuration file and I don't know what configuration is right. I actually tested one and didn't work for me (website redirect infinite loop when docker is on).

If you know some guide to configure varnish in docker that you know it works I would be grateful if you can link it here.

Thank you very much for helping me.
 
Hi again,
So finally I could run varnish with docker on my development server, I had a lot of trouble making wordpress running in https with varnish, always gave me infinite loop redirection but at the end it worked. I had to activate https with Really simple SSL plugin on wordpress, deactivate https redirection on plesk and add the next configuration in 'wp-config.php' :
define('FORCE_SSL_ADMIN', true);
$_SERVER['HTTPS']='on';

Also testing varnish on a wordpress where I was logged in was always giving me 'x-cache: MISS', but if I test that in incognito or proxy it actually says HIT so it seems to be fine.

Now I have another problem, in my development server I can use varnish with docker correctly but in my production server (is exactly the same as the development, plesk obsidian with centos 7) its not working, always getting the varnish connection error:

Error 503 Backend fetch failed
Backend fetch failed

Guru Meditation:
XID: 32789

Varnish cache server

Even with the varnish configured correctly, the same as in development, something is making this conection fail and I tested a lot of things but its still the same.
Have some ideas about what can it can be? I'm sure that the default.vcl of varnish is correct, something else is wrong.

Thank you very much.
 
I have the same problem.

I have populated several images and versions of varnish in docker. But for some reason with Plesk Onyx it did work but not with Obsidian.

Anyone know any solution?
 

There is a one thing this document doesn't explain.

You have to open port 7080 in your firewall this to work.Firefox_Screenshot_2020-02-22T09-44-02.892Z.png

I'm running the Dockers on 172.17.0.x . I have opened the port 7080 for 172.17.0.1-255
 
Last edited:
A Backend fetch failed can also be due to low timeout values in your Varnish VCL - try tweaking it;

backend default {
.host = "127.0.0.1";
.port = "8080";
.first_byte_timeout = 30000s;
.connect_timeout = 10000s;
.between_bytes_timeout = 10000s;

}
 
Thanks for the Information, I will try your suggestion. Has the .host IP really be the Servers IP, or can the Docker IP, be a "Dummy" IP??
 
Ok, Thx Gateway Docker Container is also 172.17.0.1

FW Rule Allow incoming 172.17.0.1/24 on Port 7080 TCP set

Checked all the settings, Docker is up and running Proxy Rule on Sub Domain is set. When I try now to open the page
I get redirected to the default htdocs page of plesk .. , strange


When disabling the FW Rule I get

Error 503 Backend fetch failed
Backend fetch failed

Guru Meditation:
XID: 65539

Varnish cache server
 
Last edited:
The Docker Image is: million12/varnish

/etc/varnish/default.vcl

.host = Website IP = Server IP
.port = 7080

Additional Script:

Screenshot 2020-06-28 at 09.23.00.png


Screenshot 2020-06-28 at 13.47.45.png


Under Domain Docker Proxy Rule:

Screenshot 2020-06-28 at 13.50.20.png

Firewall Rule:

Screenshot 2020-06-28 at 13.52.11.png

The Issue seems, that before configuring all the Docker Settings, when I set under Hosting Settings to not use https redirect and ssl support, the redirect dont go to http version, instead to the Default Webpage of Plesk.
 
The Issue seems, that before configuring all the Docker Settings, when I set under Hosting Settings to not use https redirect and ssl support, the redirect dont go to http version, instead to the Default Webpage of Plesk.

So the issue is not with your Varnish Docker.

when I set under Hosting Settings to not use https redirect and ssl support, the redirect dont go to http version, instead to the Default Webpage of Plesk.

You should troubleshoot this first.

After seen two threads regarding the same issue, I tried a Wordpress website with Varnish Configuration for WordPress running on Plesk Onyx VCL. I'm not able to recreate the issue.

I'm on,

CentOS Linux 7.7.1908 (Core)
Plesk Obsidian
Version 18.0.27 Update #1

I have been using Varnish Docker for many Magento 2 websites without any issue.

As I mentioned before, There are few things this article Varnish for WordPress in a Docker container does not explain but these are unrelated to the issue you are experiencing right now.

- Opening port 7080 for Docker IP
- Adding Docker IP to Fail2ban (Your Docker IP will get blocked by Fail2Ban as a Bad-Bot)

Other than that. Everything is working fine for me for the last two years.
 
Thanks a Lot for the information. I will open an other issue, when the redirects are fixed, will try again to get docker with varnish working.

Thanks a Lot!
 
Back
Top