Oct 27, 2017
9
1
3
Albania
cPanel Access Level
Root Administrator
Hello

I have some days trying to setup Nginx => Varnish = > Apache.

Nginx As main web server because we need SSL support, Varnish for Cache and Apache as it is by default just port will change..

So the idea is just to speed up websites who are hosted by us also security. I'm not saying that Apache has no security but i like Nginx and in this way it will be more easy for me to manage then i can manage Apache.

And so i started to work with it. Firstly i have install Nginx (nginx/1.13.4 (nginx-plus-r13)) + varnish (v5.2) and the setup as of now is

Nginx => PORT : 80
Varnish => PORT : 8080
Apache => PORT : 8787

The setup of Nginx As a reverse proxy has the same config files of Engintron Plugin (just proxy rules, cache settings has been removed), The varnish has no configuration file because i'm trying to make it to work then optimize it.
First problem was that varnish was sending SERVER IP to apache and not X-Forwarded-For header, then i added
Code:
  unset req.http.X-Forwarded-For;
  set req.http.X-Forwarded-For = req.http.X-Real-IP;
Now i'm getting the real client ip in apache logs (at WHM). but still my problem is here i cannot see website content but cPanel default page (scr attached)

All the time i have use just Nginx this is my first time trying and working with Varnish and maybe i'm doing something wrong or should i add something else to varnish configuration ?
i tried to add
Code:
set req.http.X-Forwarded-Host = req.http.X-Forwarded-Host;
But no result...
i also tried to set to varnish config file other headers (X-Forwarded-Port, X-Forwarded-Server, X-Forwarded-Proto) but no result again..
I have try to see around logs and other stuff for nginx varnish and apache but no luck still i cannot find what's wrong..

Can someone help about this please?!

Currently i have this setup done! But is not like this Everything in one server, it's
Server1 : cPanel Apache Running on port : 80
Server2 : Varnish running on port 80
Server3 : Nginx running on port 80

Traffic goes Nginx => Varnish => cPanel
And it works! But i don't know why it doesn't work when i setup everything into cPanel server!
May you will say when it's already done why you need this? Well in the way which i have i will need to setup each new domain configurations up manually.. my current cPanel server can handle them so as of now there is no reason using 2 additional servers when everything can be used in one!

Thanks.
 

Attachments

Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

I've moved this to our Workarounds forum so you may receive user-feedback to your topic. Note that this type of setup is unsupported, so you may want to consult with a system administrator for additional assistance. We provide a list of system admin services at:

System Administration Services | cPanel Forums

Thank you.
 
  • Like
Reactions: Xhuljo Skendaj

dimtsef

Registered
Mar 31, 2021
4
2
3
greece
cPanel Access Level
Root Administrator
any luck fixing this ?? i have the same issue with default page showing !

Hello

I have some days trying to setup Nginx => Varnish = > Apache.

Nginx As main web server because we need SSL support, Varnish for Cache and Apache as it is by default just port will change..

So the idea is just to speed up websites who are hosted by us also security. I'm not saying that Apache has no security but i like Nginx and in this way it will be more easy for me to manage then i can manage Apache.

And so i started to work with it. Firstly i have install Nginx (nginx/1.13.4 (nginx-plus-r13)) + varnish (v5.2) and the setup as of now is

Nginx => PORT : 80
Varnish => PORT : 8080
Apache => PORT : 8787

The setup of Nginx As a reverse proxy has the same config files of Engintron Plugin (just proxy rules, cache settings has been removed), The varnish has no configuration file because i'm trying to make it to work then optimize it.
First problem was that varnish was sending SERVER IP to apache and not X-Forwarded-For header, then i added
Code:
  unset req.http.X-Forwarded-For;
  set req.http.X-Forwarded-For = req.http.X-Real-IP;
Now i'm getting the real client ip in apache logs (at WHM). but still my problem is here i cannot see website content but cPanel default page (scr attached)

All the time i have use just Nginx this is my first time trying and working with Varnish and maybe i'm doing something wrong or should i add something else to varnish configuration ?
i tried to add
Code:
set req.http.X-Forwarded-Host = req.http.X-Forwarded-Host;
But no result...
i also tried to set to varnish config file other headers (X-Forwarded-Port, X-Forwarded-Server, X-Forwarded-Proto) but no result again..
I have try to see around logs and other stuff for nginx varnish and apache but no luck still i cannot find what's wrong..

Can someone help about this please?!

Currently i have this setup done! But is not like this Everything in one server, it's
Server1 : cPanel Apache Running on port : 80
Server2 : Varnish running on port 80
Server3 : Nginx running on port 80

Traffic goes Nginx => Varnish => cPanel
And it works! But i don't know why it doesn't work when i setup everything into cPanel server!
May you will say when it's already done why you need this? Well in the way which i have i will need to setup each new domain configurations up manually.. my current cPanel server can handle them so as of now there is no reason using 2 additional servers when everything can be used in one!

Thanks.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
@dimtsef - since the earlier portions of this thread are nearly 4 years old, the configurations would be completely different now as our Nginx implementation has changed several times. It would be best to open a new thread about the specific problems you're experiencing so we can check that.
 

dimtsef

Registered
Mar 31, 2021
4
2
3
greece
cPanel Access Level
Root Administrator
well i found out the issue so i want to share it ! it was the default.vcl configuration error , on the backend configuration instead of 127.0.0.1 we have to replace it with the external ip of the server. restart the services and fixed !
 
  • Like
Reactions: SS-Maddy