• 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.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Plesk 12.0.18 502 Nginx issues with WHMCS v5.3.10

Xavier12

Regular Pleskian
Hey guys,

This is has been driving me insane.. I've set up WHMCS correctly where it works fine, but the problem is when I am navigating through the menus to different pages (which are php) a random 502 bad gateway error appears where I end up having to reload/refresh the page for the page to load up. It happens every 2-4 pages navigated and I just cannot figure out what the issue is.. I can setup wordpress sites and other php scripts perfectly fine, but for some reason this isn't working

Please advise, thank you!
 
Hi Xavier12,

WHMCS provides these rewrite - rules at: http://docs.whmcs.com/Support_Center#Nginx

HTML:
# Announcements
rewrite ^/announcements/([0-9]+)/[a-zA-Z0-9-]+\.html$ /./announcements.php?id=$1 last;
rewrite ^/announcements$ /./announcements.php last;
# Downloads
rewrite ^/downloads/([0-9]+)/([^/]*)$ /./downloads.php?action=displaycat&catid=$1 last;
rewrite ^/downloads$ /./downloads.php last;
#Knowledgebase
rewrite ^/knowledgebase/([0-9]+)/[a-zA-Z0-9-]+\.html$ /./knowledgebase.php?action=displayarticle&id=$1 last;
rewrite ^/knowledgebase/([0-9]+)/([^/]*)$ /./knowledgebase.php?action=displaycat&catid=$1 last;
rewrite ^/knowledgebase$ /./knowledgebase.php last;

If you still experience issues, please provide some more informations ( error - logs and configurations - files ), so that further investigations and suggestions could be made.

 
Hey,

Thanks for the response! I did try that before, it didn't work. Now I even tried to log in again, and all I receive is a 502 error. For some reason it looks like a memory issue with php because now I can't log in at all. But my server has more than enough memory, cpu usage is very low and I can also install wordpress websites quite fine

Here is the proxy error log and error log file for the website, it was located on the root of the domain. Please let me know if this is correct.

Please advise, thnx
 

Attachments

  • error_log.txt
    181.4 KB · Views: 2
  • proxy_error_log.txt
    218.6 KB · Views: 2
Hi Xavier12,

first, I suggest to modify your main - nginx.conf ( which you posted ), because you left out any global log - definitions. To investigate issues/problems/failures it it much easier, when you log all errors... and not only the ones from the domains.

Second... is there a reason, why you uncommented the "pid" - file usage? The standard configuration is "pid /var/run/nginx.pid;", just to make sure, that it could be as well monitored and in case of kills or unwanted stops, it might be restarted automatically ( see Plesk-AddOn "watchdog" ).

Usefull examples for nginx.conf :
Code:
...

error_log  /var/log/nginx/error.log  info;

...

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    tcp_nopush    on;
    tcp_nodelay   off;

    sendfile      on;

    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    keepalive_requests 100000;
    keepalive_timeout  120;

...

Third... you have quite a lot of FastCGI - failures.
Please post the depending pool - settings at "/etc/php5/fpm/pool.d/" ( files: "www.conf" and depending config - files for the specific domain named as "example.com.conf" and "subdomain.example.com.conf" ) for your domains, for further investigations.

Fourth... please include as well your apache ( last_httpd.conf ) and nginx ( last_nginx.conf ) configurations files for your domain ( located at "/var/www/vhosts/system/(subdomain.)example.com/conf" ) and include as well the additional vhosts - files, if there is any content in them.
( Be aware that in some cases, the apache and nginx - files are named with the addition "_ip_" )

Please include some basic informations, if you edited your apache and/or nginx - config - files for the domain by hand in the past, or if you let Plesk configure it over the Plesk Control Panel.

Fifth... to avoid "File does not exist" - notifications in your domain specific error - logs, you might consider to use a "robots.txt" - file ( even that it might be an empty file ) and as well a "favicon.ico" in the document root of your domain, because most robots look for these files all day long.
 
Last edited by a moderator:
Sixth... to shorten your logs... you might as well consider using logrotate on a daily basis for the domain-specific apache and nginx log - files.
 
Hi,

Thanks for the update and response! Attached are the files, for some reason I could not copy the last_nginx.conf and last_httpd.conf.. its size shows -- and does not copy.

Please let me know if I am missing anything else. As far as the original nginx.conf, the default file commented out many of the sections that you spoke of.

Please advise, thnx.
 

Attachments

  • Files.zip
    11.2 KB · Views: 2
Only thing I edited in nginx conf were adding gzip and modifying the worker process and connections based on server ram and cores.

Please advise, thnx!
 
... just a statement to the copy issues... the rest will follow after investigations:

The two mentioned files are symlinks to the last saved http.- and nginx.config - files... you already included them in your complete folder, because you hit the "in some cases part" with the "_ip_ - files" ^^
 
Hi again Xavier12,

... some recommendations:

for www.conf:
  • Change
;catch_workers_output = yes
to
catch_workers_output = yes
  • Change ( please make sure, that the values meet YOUR OWN configuration... i.e. locate your php/perl/python - locations, because they vary on several linux distributions! )
Code:
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
to
Code:
env[HOSTNAME] = $HOSTNAME
env[PATH] = /bin:/usr/bin:/usr/local/bin:/usr/share/php:/usr/share/php5:/usr/share/perl:/usr/share/perl5:/usr/bin/python:/usr/bin/python3:/usr/share/psa-pear
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
  • Change
;php_admin_flag[log_errors] = on​
to
php_admin_flag[log_errors] = on
  • Add ( at the end and again: please make sure, that the values meet YOUR OWN configuration... i.e. locate your php/perl/python - locations, because they vary on several linux distributions! )
Code:
php_value[include_path] = ".:/bin:/usr/bin:/usr/local/bin:/usr/share/php:/usr/share/php5:/usr/share/perl:/usr/share/perl5:/usr/bin/python:/usr/bin/python3:/usr/share/psa-pear"
  • After you finished editing the www.conf, consider renaming the file to "zzz_www.conf" ( or something similar ), to make sure, that Plesk or any other configurator will not override your own modifications for your global www.conf. Keep in mind, that if you add domains or modify some hosting - settings, Plesk might build another www.conf, because it thinks, that it might not be existent, when you renamed it.

for example.com.conf ( renamed to "example.com" to secure your personel informations ) :

  • Change
Code:
php_value[max_execution_time] = 30
php_value[memory_limit] = 500M
php_value[open_basedir] = "/var/www/vhosts/example.com/:/tmp/"
to ( at the end and again: please make sure, that the values meet YOUR OWN configuration... i.e. locate your php/perl/python - locations, because they vary on several linux distributions! )

Code:
php_value[allow_url_fopen] = on
php_value[safe_mode] = off

php_value[memory_limit] = 512M
php_value[max_input_time] = 360
php_value[max_execution_time] = 360
php_value[post_max_size] = 256M
php_value[upload_max_filesize] = 192M

php_value[include_path] = ".:/bin:/usr/bin:/usr/local/bin:/usr/share/php:/usr/share/php5:/usr/share/perl:/usr/share/perl5:/usr/bin/python:/usr/bin/python3:/usr/share/psa-pear"
php_value[open_basedir] = "/var/www/vhosts/example.com/:/tmp/:/bin:/usr/bin:/usr/local/bin:/usr/share/php:/usr/share/php5:/usr/share/perl:/usr/share/perl5:/usr/bin/python:/usr/bin/python3:/usr/share/psa-pear"

php_admin_flag[engine] = on
  • After you finished editing the example.com.conf, consider renaming the file to "zzz_example.com.conf" ( or something similar ), to make sure, that Plesk or any other configurator will not override your own modifications for your domain-specific example.com.conf. Keep in mind, that if you add domains or modify some hosting - settings, Plesk might build another example.com.conf, because it thinks, that it might not be existent, when you renamed it.
You might notice, that I recommend higher/other PHP values, which you should as well change in your custom PHP - settings either over the webhosting - settings on the Plesk Control Panel, or directly at: /var/www/vhosts/system/example.com/etc/php.ini
Be aware that if you change it over the Plesk Control Panel, Plesk will override any existent example.com.conf, which you just edited manually ( therefore the suggestion to rename this file ^^ ).
I noticed, that your server is still vulnerable, because of the poodle vulnerability. Please consider reading:

Your standard configuration for the fcgid.conf could be optimized, please see the following KB - article ( Domain shows 500 internal server error: mod_fcgid: read data timeout ( KB - article 121 251 ) ) , even if the KB - article doesn't describe your specific issue. Consider setting another fcgid.conf - configuration, as suggested by Parallels, which is a bit more specific and more detailled:

Code:
# This is the Apache server configuration file for providing FastCGI support
# via mod_fcgid
#
# Documentation is available at http://fastcgi.coremail.cn/doc.htm


<IfModule mod_fcgid.c>

<IfModule !mod_fastcgi.c>
    AddHandler fcgid-script fcg fcgi fpl
</IfModule>

  FcgidIPCDir /var/lib/apache2/fcgid/sock
  FcgidProcessTableFile /var/lib/apache2/fcgid/shm

  FcgidInitialEnv RAILS_ENV production

  FcgidIdleTimeout 3600
  FcgidBusyTimeout 1800

  FcgidProcessLifeTime 0

  FcgidMaxProcesses 150
  FcgidMaxRequestsPerProcess 500
  FcgidMaxProcessesPerClass 20

  FcgidMinProcessesPerClass 0

  FcgidConnectTimeout 60
  FcgidIOTimeout 1800

  MaxRequestLen 2147483648
  FcgidMaxRequestLen 2147483648

  FcgidIdleScanInterval 480
  FcgidZombieScanInterval 12
  FcgidErrorScanInterval 12

  FcgidSpawnScoreUpLimit 10
  FcgidSpawnScore 1

  FcgidTerminationScore 2

</IfModule>

... but please still change the custom "domainVirtualHost.php", as described in the mentioned article, but with the difference to modify the custom template like this:

Code:
FcgidMaxRequestLen 2147483648
FcgidIOTimeout 1800

If you experience problems with this part ( misunderstanding of the KB - article, unsure about how to create custom templates... ), please reply again, so you could get specific further suggestions on this behalf.


Another issue/problem/failure/cause might be, that you missed to recreate the templates after some modifications. This can be resolved with the command:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
or
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain YOURDOMAIN.COM


If you still experience further issues/problems, even if you restarted apache, nginx and php5-fpm with the commands:

service apache2 restart && service nginx restart && service php5-fpm restart
( please keep in mind, that on some linux systems the command to restart apache is "service httpd restart" ), you could try to use the bootstrapper command, which solves quite a lot ot issues:

/usr/local/psa/bootstrapper/pp12.0.18-bootstrapper/bootstrapper.sh repair

and make sure, that your Plesk installation is up-to-date:

/usr/local/psa/admin/bin/autoinstaller --select-product-id plesk --select-release-current --reinstall-patch --install-component base


Don't hesitate to include again error - logs and configuration files as done before... but shorten the logs to the actual date please, so that investigations are faster, if you experience further issues. Please include then as well all config files from "/var/www/vhosts/system/example.com/conf"
 
Wow.. didn't know the default setup for plesk required so many modifications.

So, starting with www.conf, you mentioned about my own configuration, are you meaning that for example:
;env[HOSTNAME] = $HOSTNAME

should be something like

env[HOSTNAME] = $MYHOSTNAMEHERE ?

Please advise
 
Hi Xavier12,

no, the code "env[HOSTNAME] = $HOSTNAME" has to be like this... no modification, please.
In the case of python, please use your very own python location, please and not the one, that I suggested.
 
Done! thanks for this.. I am stuck on this part

".. but please still change the custom "domainVirtualHost.php", as described in the mentioned article, but with the difference to modify the custom template like this:"

Where is the domainVirtualhost.php located?


UPDATE: Nevermind, found it
 
Came across this error when reconfiguring all domains

Details: [2014-11-30 10:16:53] ERR [util_exec] proc_close() failed
[2014-11-30 10:17:01] ERR [panel] Apache config (14173425930.89344900) generation failed: Template_Exception: Syntax error on line 60 of /etc/apache2/plesk.conf.d/ip_default/mydomain.com.conf:
Invalid command '30', perhaps misspelled or defined by a module not included in the server configuration

file: /opt/psa/admin/plib/Template/Writer/Webserver/Abstract.php
line: 75
code: 0
Syntax error on line 60 of /etc/apache2/plesk.conf.d/ip_default/mydomain.com.conf:
Invalid command '30', perhaps misspelled or defined by a module not included in the server configuration
 
Last edited:
Please post the line 60 from "/etc/apache2/plesk.conf.d/ip_default/MYDOMAIN(Thisisyourdomain).com.conf" to investigate your command "30" there ( it is again a symlink... please post your file "/var/www/vhosts/system/MYDOMAIN(Thisisyourdomain).com/conf/httpd_ip_default.conf" )
 
Last edited by a moderator:
Line 60 was </ifModule> but here is the whole section of that code.

<IfModule mod_fcgid.c>
FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/mydomain.com/etc/php.ini
FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
FcgidMaxRequestLen 134217728
FcgidIOTimeout 30
</IfModule>

I am guessing it has to match the fgcidmaxrequest from before? Also, attached is the http_ip_default.conf as requested
 

Attachments

  • httpd_ip_default.conf.txt
    9 KB · Views: 2
Last edited:
Could you please check, that the "FcgidIOTimeout 30" has no hidden spaces, or other invisible code? You should as well consider again to change the ( possible ) custom template at "domainVirtualHost.php", which should then be located at "/usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php" as described above:
Code:
FcgidMaxRequestLen 2147483648
FcgidIOTimeout 1800

Afterwards, please reconfigure again your domain please, with the command:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
or
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain YOURDOMAIN.COM
 
Apart from this last issue, I just saw that you are still vulnerable ( poodle )... so I think you left out these changes from the suggested mentioned KB - article above?
 
Back
Top