Control Web Panel

WebPanel => PHP => Topic started by: AdventureTime on March 10, 2022, 05:15:44 AM

Title: 502 Bad Gateway
Post by: AdventureTime on March 10, 2022, 05:15:44 AM
Hello,

I have installed PHP-FPM and changed my webserver from Apache to either Nginx or Nginx + Varnish Cache. However, I am receiving a 502 Bad Gateway message for my website, which is the initial installation of WordPress.

I have selected the latest version of PHP, which is something like 7.4.28.

May you please help me?

Thanks!
Title: Re: 502 Bad Gateway
Post by: rcschaff on March 10, 2022, 05:26:57 AM
Please make sure you have a pro license, or any verison of FPM will be disabled automatically.  If you do have pro, make sure you start the PHP-FPM service

systemctl start php-fpm74
systemctl enable php-fpm74
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 10, 2022, 05:49:23 AM
Please make sure you have a pro license, or any verison of FPM will be disabled automatically.  If you do have pro, make sure you start the PHP-FPM service

systemctl start php-fpm74
systemctl enable php-fpm74

I am happy to say that I am now using the pro version.

(https://i.imgur.com/WKlbJKg.png)

However, I only see the following even after enabling PHP-FPM

(https://i.imgur.com/TGhsRmJ.png)
Title: Re: 502 Bad Gateway
Post by: rcschaff on March 10, 2022, 06:01:10 AM
You may need to rebuild your configs after enabling fpm
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 10, 2022, 06:58:00 AM
You may need to rebuild your configs after enabling fpm

I found the issue. I tried to explore these first:

(https://i.imgur.com/DLHsrut.png)

I honestly don't know the difference between the two.

Moving forward, I checked the User Accounts > List Accounts and I noticed the Domain Name has a missing .com that is why it does not work. I fixed it by deleting and recreating the User Account again.
To my surprise, it worked. To be sure, I did the Fix Permissions stuff and Web Server Settings > Web Servers Main Conf / Web Servers Domain Conf.

Finally, it worked!
Title: Re: 502 Bad Gateway
Post by: rcschaff on March 10, 2022, 07:09:57 AM
Main config is for ALL of your accounts that don't have specific configurations.  Domain Config allows you to use a different template for an individual account, or domain.  Once you explore some more, you will get the hang of it.
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 10, 2022, 08:51:06 AM
Main config is for ALL of your accounts that don't have specific configurations.  Domain Config allows you to use a different template for an individual account or domain.  Once you explore some more, you will get the hang of it.

I thought it was something that would be mandatory for domains to have. At least now I know. I don't wholly understand the template's purpose, but I think either I will use default or php-fpm as the template, right?
Title: Re: 502 Bad Gateway
Post by: rcschaff on March 10, 2022, 12:09:50 PM
Main config is for ALL of your accounts that don't have specific configurations.  Domain Config allows you to use a different template for an individual account or domain.  Once you explore some more, you will get the hang of it.

I thought it was something that would be mandatory for domains to have. At least now I know. I don't wholly understand the template's purpose, but I think either I will use default or php-fpm as the template, right?

Yes.  Set the Main config to Default is fine.  I

As to the Domain Configs, let's say you have a Joomla site, that requires specific settings from apache or nginx.  You can create a new template with those specific settings, and set that domain to use it.  NEVER edit the config files directly, because any changes made can be overwritten on an update of CWP, or a config rebuild
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 10, 2022, 04:07:32 PM
Main config is for ALL of your accounts that don't have specific configurations.  Domain Config allows you to use a different template for an individual account or domain.  Once you explore some more, you will get the hang of it.

I thought it was something that would be mandatory for domains to have. At least now I know. I don't wholly understand the template's purpose, but I think either I will use default or php-fpm as the template, right?


Yes.  Set the Main config to Default is fine.  I

As to the Domain Configs, let's say you have a Joomla site, that requires specific settings from apache or nginx.  You can create a new template with those specific settings, and set that domain to use it.  NEVER edit the config files directly, because any changes made can be overwritten on an update of CWP, or a config rebuild

Thank you!

I activated the AutoSSL feature through Let's Encrypt.
Now I always receive a 403 Forbidden message.
I changed the type of web server from nginx + Varnish Cache to nginx only, vice-versa.

I am still receiving a 403 message whenever I visit my site both SSL and non-SSL version of it.
Title: Re: 502 Bad Gateway
Post by: rcschaff on March 10, 2022, 05:02:01 PM
403 errors typically means that you have permission issues.  make sure directories are chmod 755, and files 644 in your web roots.  Also make sure the files are owned by the user
Title: Re: 502 Bad Gateway
Post by: iraqiboy90 on March 10, 2022, 05:28:54 PM
Code: [Select]
I am still receiving a 403 message whenever I visit my site both SSL and non-SSL version of it.
Do you have mod_security enabled by any chance? It may be blocking a script that runs when you visit the page?
Either way, 403 message is usually user related. Meaning you added something that's blocking you.
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 11, 2022, 03:08:57 AM
Code: [Select]
I am still receiving a 403 message whenever I visit my site both SSL and non-SSL version of it.
Do you have mod_security enabled by any chance? It may be blocking a script that runs when you visit the page?
Either way, 403 message is usually user related. Meaning you added something that's blocking you.

Yes, I have mod_security enabled.
Also, the 403 message started to appear when I used AutoSSL and received the Let's Encrypt certificate.
Title: Re: 502 Bad Gateway
Post by: rcschaff on March 11, 2022, 04:01:06 AM
you should also check the /usr/local/apache/domlogs/  for both the access and error logs.  They should give some insight as to why you are receiving 403 errors.
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 11, 2022, 06:13:11 AM
you should also check the /usr/local/apache/domlogs/  for both the access and error logs.  They should give some insight as to why you are receiving 403 errors.

I am mainly using nginx.
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 11, 2022, 09:43:08 AM
I have removed the AutoSSL thing, and it still says 403 Forbidden. The website would work if I tried using simply Apache or nginx + Varnish + Apache. I decided to use CWP Pro to install php-fpm[/] and avoid Apache altogether. Any thoughts about why making nginx the primary server does not work? Thanks.
Title: Re: 502 Bad Gateway
Post by: rcschaff on March 11, 2022, 12:57:28 PM
Nginx cannot run without php-fpm.  Apache uses built in modules to connect to php.  Nginx does not have those, so it requires a standalone version of php such as php-cgi or php-fpm
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 14, 2022, 04:35:25 AM
Nginx cannot run without php-fpm.  Apache uses built-in modules to connect to php.  Nginx does not have those, so it requires a standalone version of php such as php-cgi or php-fpm

Yes, I agree. That is why I purchased and subscribed to the CWP Pro version to support its development.
However, I noticed I could not use nginx alone. I would need to use something that has Apache for it to work.
Is it because it is incompatible with the latest version of 7.4 of PHP? Or do I need to use the last 5.6 version?

My current configuration is nginx > varnish > apache.
I prefer either nginx alone or nginx > varnish.

I accidentally solved it.
I pressed fixed permission when user nobody is selected.

nginx alone works now.
and nginx > varnish still doesn't work though.

(https://i.imgur.com/duTxMaw.png)

Also, I don't understand this:

Code: [Select]
Nginx & Varnish
Additional Options: nginx/php-fpm, proxy
HTTP: Nginx (80) --> Varnish (82)
HTTPS: Nginx (443) --> Varnish (82)
Info: Useful as nginx/varnish proxy cache for NodeJS, Ruby, Tomcat
** Requires custom configuration per domain, as default behavior is proxy to varnish.
** Varnish you can enable additionally for domains you need.

What does it require and what do I need to do?
Title: Re: 502 Bad Gateway
Post by: studio4host on March 14, 2022, 06:24:55 AM
nginx + varnish can be used only if you proxy varnish to the custom app, like nodejs, tomcat....
if you want to use php then you can use only the option where the last server is nginx or apache.

However, you can also set per domain to use nginx + php-fpm if you have selected nginx/varnish webserver setup.
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 14, 2022, 09:00:10 AM
nginx + varnish can be used only if you proxy varnish to the custom app, like nodejs, tomcat....
if you want to use php then you can use only the option where the last server is nginx or apache.

However, you can also set per domain to use nginx + php-fpm if you have selected nginx/varnish webserver setup.

Oh wait. I can't use Varnish for WordPress?
How to proxy it or something?
Title: Re: 502 Bad Gateway
Post by: iraqiboy90 on March 14, 2022, 10:51:07 AM
Why don't you make your life easier by switching to Nginx & Varnish & Apache and then assign "Nginx -> php-fpm" to those sites you insist on having it "nginx - php-fpm"?

Basically, make your wordpress run with Nginx - Varnish - Apache.
Varnish needs to be manually enabled by re-selecting this webserver configuration through the WebServer Domain Conf.
There you can choose a varnish template made for wordpress.

My wordpress site is running like this with varnish.
Title: Re: 502 Bad Gateway
Post by: Eddie on March 14, 2022, 12:04:54 PM
nginx + varnish can be used only if you proxy varnish to the custom app, like nodejs, tomcat....
if you want to use php then you can use only the option where the last server is nginx or apache.

However, you can also set per domain to use nginx + php-fpm if you have selected nginx/varnish webserver setup.

Oh wait. I can't use Varnish for WordPress?
How to proxy it or something?

You can check our wiki how to use Varnish,

http://wiki.centos-webpanel.com/how-to-install-varnish
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 14, 2022, 12:33:50 PM
Why don't you make your life easier by switching to Nginx & Varnish & Apache and then assign "Nginx -> php-fpm" to those sites you insist on having it "nginx - php-fpm"?

Basically, make your wordpress run with Nginx - Varnish - Apache.
Varnish needs to be manually enabled by re-selecting this webserver configuration through the WebServer Domain Conf.
There you can choose a varnish template made for wordpress.

My wordpress site is running like this with varnish.
I tried to make my life easier too. However, I prefer to avoid Apache because it is completely unstable. I have seen the performance of nginx and it seems that completely utilizing nginx is the way to go...
Title: Re: 502 Bad Gateway
Post by: AdventureTime on March 14, 2022, 01:03:55 PM
nginx + varnish can be used only if you proxy varnish to the custom app, like nodejs, tomcat....
if you want to use php then you can use only the option where the last server is nginx or apache.

However, you can also set per domain to use nginx + php-fpm if you have selected nginx/varnish webserver setup.

Oh wait. I can't use Varnish for WordPress?
How to proxy it or something?

You can check our wiki how to use Varnish,

http://wiki.centos-webpanel.com/how-to-install-varnish

Thanks for this!