502 bad gateway nginx

broken reverse proxy config destination ? for sure nginx works fine and mysql goes crazy.
use htop, it's bit better.
hard to help without knowing the full picture.
 
Centos, nginx version 1.16.0
My VPS has option to reinstall VPS, I did not backup anything. The problem is that I do not update or install anything ):
I feel its gonna be hard to find the problem remotely, I believe it is gonna be easier and faster for you to backup and do a clean install
 
broken reverse proxy config destination ? for sure nginx works fine and mysql goes crazy.
use htop, it's bit better.
hard to help without knowing the full picture.
Image not found: TfZ8SLx
 
I feel its gonna be hard to find the problem remotely, I believe it is gonna be easier and faster for you to backup and do a clean install
I do not want to reinstall it, this is the third time I reinstall and the problem still exists
 
I do not want to reinstall it, this is the third time I reinstall and the problem still exists
I dont know what specific needs you have, but you can try with another package installer like vestacp, or if you can afford it, why not cpanel. I want to believe that if you are kinda new with linux and web hosting you are not doing anything super complex either so even a regular hosting might be good for you
 
My site was working before. I used this script to install a complete VPS
curl -sO https://hocvps.com/install && bash install

First of all, you do not need any script, you only need to install a few things and run a couple commands to have a working wordpress site.
I just took a look at that script. It tries to do so many things, including completely replacing your default nginx config. I think the best course of action is to completely reinstall your OS and do things right from the beginning WITHOUT that script. If you do not want to setup everything from scratch, you can try to reinstall and reconfigure nginx (at your own risk, I can't guarantee it will work without taking a deeper look)

Before you try doing the following, you must know the path to your web root (usually /var /www/ html/ something) and the paths to your https cert and private key, and you must have php 7.0 installed.

Code:
yum erase nginx
yum install nginx

Then, using a text editor of your choice, create the file "/etc/nginx/conf.d/xxtap80.conf"

And paste the following:

Code:
server {
   listen 139.99.96.145:80;
   listen [::]:80;
   server_name xxtap.com;
   return 301 https://xxtap.com$request_uri;
}

This will redirect all HTTP requests to HTTPS.

Then create the file "/etc/nginx/conf.d/xxtap443.conf" and paste the following:

Code:
server {
   listen 139.99.96.145:443;
   listen [::]:443;
   root /change/this/path/to/your/web/root;
   index  index.php index.html index.htm;
   server_name xxtap.com;
   gzip on;
   gzip_types text/html text/plain application/xml text/javascript text/css;
   gzip_min_length 800;

   ssl on;
   ssl_certificate /change/this/path/to/ssl/cert.pem;
   ssl_certificate_key /change/this/path/to/privkey.pem;

   location / {
   try_files $uri $uri/ /index.php?$args;       
   }

   location ~ \.php$ {
   fastcgi_split_path_info  ^(.+\.php)(/.+)$;
   fastcgi_index            index.php;
   fastcgi_pass             unix:/var/run/php/php7.0-fpm.sock;
   include                  fastcgi_params;
   fastcgi_param   PATH_INFO       $fastcgi_path_info;
   fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }
   location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
       expires 365d;
   }
}

This is the basic config I use on most of my sites.
 
Last edited:
I dont know what specific needs you have, but you can try with another package installer like vestacp, or if you can afford it, why not cpanel. I want to believe that if you are kinda new with linux and web hosting you are not doing anything super complex either so even a regular hosting might be good for you
But the hosting package usually limits the number of nodes although it states "unlimited"
 
First of all, you do not need any script, you only need to install a few things and run a couple commands to have a working wordpress site.
I just took a look at that script. It tries to do so many things, including completely replacing your default nginx config. I think the best course of action is to completely reinstall your OS and do things right from the beginning WITHOUT that script. If you do not want to setup everything from scratch, you can try to reinstall and reconfigure nginx (at your own risk, I can't guarantee it will work without taking a deeper look)

Before you try doing the following, you must know the path to your web root (usually /var /www/ html/ something) and the paths to your https cert and private key, and you must have php 7.0 installed.

Code:
yum erase nginx
yum install nginx

Then, using a text editor of your choice, create the file "/etc/nginx/conf.d/xxtap80.conf"

And paste the following:

Code:
server {
   listen 139.99.96.145:80;
   listen [::]:80;
   server_name xxtap.com;
   return 301 https://xxtap.com$request_uri;
}

This will redirect all HTTP requests to HTTPS.

Then create the file "/etc/nginx/conf.d/xxtap443.conf" and paste the following:

Code:
server {
   listen 139.99.96.145:443;
   listen [::]:443;
   root /change/this/path/to/your/web/root;
   index  index.php index.html index.htm;
   server_name xxtap.com;
   gzip on;
   gzip_types text/html text/plain application/xml text/javascript text/css;
   gzip_min_length 800;

   ssl on;
   ssl_certificate /change/this/path/to/ssl/cert.pem;
   ssl_certificate_key /change/this/path/to/privkey.pem;

   location / {
   try_files $uri $uri/ /index.php?$args;      
   }

   location ~ \.php$ {
   fastcgi_split_path_info  ^(.+\.php)(/.+)$;
   fastcgi_index            index.php;
   fastcgi_pass             unix:/var/run/php/php7.0-fpm.sock;
   include                  fastcgi_params;
   fastcgi_param   PATH_INFO       $fastcgi_path_info;
   fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }
   location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
       expires 365d;
   }
}

This is the basic config I use on most of my sites.
But many people are using this script to install the VPS ):
 

Do your mysql tables have proper indexes? Is the DB server cache enabled? One little detail can cause mysql to crawl.

There are tons of articles on debugging mysql issues. You'll need to find out what it is.

Do you have query logging enabled? Query logging will slow the server to a crawl.

Are you out of disk space? That'll also make mysql very slow.

Maybe you need to clean up your innodb metadata? They grow fairly fast and require maintenance.

Just a few ideas. Hope it helps.
 
This is my etc/my.cnf config
[client]
socket=/var/lib/mysql/mysql.sock

[mysql]
max_allowed_packet = 64M

[mysqld]
local-infile=0
ignore-db-dir=lost+found
character-set-server=utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

#bind-address=127.0.0.1
# optimized my.cnf for MariaDB 5.5.x
# by eva2000
# vbtechsupport.com

innodb=ON
#skip-federated
#skip-pbxt
#skip-pbxt_statistics
#skip-archive
#skip-name-resolve
#old_passwords
back_log = 256
max_connections = 300
key_buffer_size = 32M
myisam_sort_buffer_size = 64M
myisam_max_sort_file_size = 2048M
join_buffer_size = 128K
read_buffer_size = 128K
sort_buffer_size = 256K
table_definition_cache = 8192
table_open_cache = 4096
thread_cache_size = 128

wait_timeout = 1800
connect_timeout = 10
tmp_table_size = 128M
max_heap_table_size = 128M
max_allowed_packet = 64M
#max_seeks_for_key = 4294967295
group_concat_max_len = 1024
max_length_for_sort_data = 1024
net_buffer_length = 16384
max_connect_errors = 100000
concurrent_insert = 2
read_rnd_buffer_size = 256K
bulk_insert_buffer_size = 8M
# query_cache boost for MariaDB >10.1.2+
# https://community.centminmod.com/posts/30811/
query_cache_limit = 1024K
query_cache_size = 64M
query_cache_type = 1
query_cache_min_res_unit = 2K
query_prealloc_size = 262144
query_alloc_block_size = 65536
transaction_alloc_block_size = 8192
transaction_prealloc_size = 4096
default-storage-engine = InnoDB

log_warnings=1
slow_query_log=0
long_query_time=1
slow_query_log_file=/home/xxtap.com/logs/mysql-slow.log
log-error=/home/xxtap.com/logs/mysql.log

# innodb settings
innodb_large_prefix=1
innodb_purge_threads=1
innodb_file_format = Barracuda
innodb_open_files = 1000
innodb_data_file_path= ibdata1:10M:autoextend
innodb_buffer_pool_size = 192M

## https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables/#innodb_buffer_pool_insta$
#innodb_buffer_pool_instances=2

innodb_log_files_in_group = 2
innodb_log_file_size = 128M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_thread_concurrency = 0
innodb_lock_wait_timeout=50
innodb_flush_method = O_DIRECT
innodb_support_xa=1
# 200 * # DISKS
innodb_io_capacity = 200
innodb_io_capacity_max = 2000
innodb_read_io_threads = 2
innodb_write_io_threads = 2
innodb_flush_neighbors = 1

# mariadb settings
[mariadb]
#thread-handling = pool-of-threads
#thread-pool-size= 20
#mysql --port=3307 --protocol=tcp
#extra-port=3307
#extra-max-connections=1

userstat = 0
key_cache_segments = 1
aria_group_commit = none
aria_group_commit_interval = 0
aria_log_file_size = 32M
aria_log_purge_type = immediate
aria_pagecache_buffer_size = 32M
aria_sort_buffer_size = 32M

[mariadb-5.5]
innodb_file_format = Barracuda
innodb_file_per_table = 1

#ignore_db_dirs=
query_cache_strip_comments=0

innodb_read_ahead = linear
innodb_adaptive_flushing_method = estimate
innodb_flush_neighbor_pages = 1
innodb_stats_update_need_lock = 0
innodb_log_block_size = 512
log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,t$

[mysqld_safe]
socket=/var/lib/mysql/mysql.sock
log-error=/home/xxtap.com/logs/mysql.log
#nice = -5
open-files-limit = 8192

[mysqldump]
quick
max_allowed_packet = 64M

[myisamchk]
key_buffer = 32M
sort_buffer = 16M
read_buffer = 16M
write_buffer = 16M
[mysqlhotcopy]
interactive-timeout

[mariadb-10.0]
innodb_file_format = Barracuda
innodb_file_per_table = 1

# 2 variables needed to switch from XtraDB to InnoDB plugins
#plugin-load=ha_innodb
#ignore_builtin_innodb

## MariaDB 10 only save and restore buffer pool pages
## warm up InnoDB buffer pool on server restarts
innodb_buffer_pool_dump_at_shutdown=1
innodb_buffer_pool_load_at_startup=1
innodb_buffer_pool_populate=0
## Disabled settings
performance_schema=OFF

innodb_stats_on_metadata=OFF
innodb_sort_buffer_size=2M
innodb_online_alter_log_max_size=128M
query_cache_strip_comments=0
log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,t$
 
Back
Top