
그래서 내 WordPress에 대한 설정이 있습니다.
모든 서버는 Centos 7 MariaDB 10.4.17 Php-FPM 7.4 PHP 7.4 NginX에서 실행됩니다.
서버 1, Front Load Balancing 서버 서버 2-3-4 NginX와 함께 제공되는 WordPress 애플리케이션 서버 4 MariaDB
Nginx 로드 밸런스 설정은 각 서버 2-3-4에서 표준 info.php를 사용하여 제대로 실행됩니다. 그들은 라운드 로빈을 사용하여 전환합니다.
WordPress는 서버 2-3-4에서 자체적으로 잘 실행됩니다. 서버의 IP 주소를 반영하기 위해 wp-options DB에 있는 wordpress의 사이트 URL과 홈 URL을 변경해야 합니다. 예를 들어 wp 서버 2를 테스트하는 경우 사이트 URL과 홈 URL은 서버 2를 가리킵니다.
두 번째로 LB 아래의 모든 서버 2-3-4를 WordPress와 결합했을 때 "페이지가 제대로 리디렉션되지 않습니다"라는 오류가 발생했습니다. Nginx 로드 밸런서에서 WP가 작동하도록 하기 위해 수행해야 하는 특정 설정이 있는지 잘 모르겠습니다. 문제를 해결하는 방법에 대한 조언이 있습니까? 도와주세요?
내 LB Nginx 구성.
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
include /etc/nginx/conf.d/*.conf;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
root /var/www/wp;
sendfile on;
keepalive_timeout 65;
log_format upstreamlog '$server_name to : $upstream_addr [$request] '
'upstream_response_time $upstream_response_time '
'msec $msec request_time $request_time';
upstream big_server_com {
ip_hash;
server 192.168.1.32;
server 192.168.1.33;
server 192.168.1.34;
}
server {
server_name myserver.net wp.myserver.net;
#acces_log /var/log/nginx/access.log upstream.log;
location ~ \.php$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
fastcgi_pass unix:/run/php-fpm/wp.sock;
fastcgi_index index.php;
proxy_pass http://big_server_com;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
try_files $uri $uri/ /index.php?$query_string;
}
index index.php;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myserver.net/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myserver.net/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
ssl_dhparam /etc/ssl/certs/dhparam.pem; # managed by Certbot
}
server {
if ($host = myserver.net) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = myserver.net) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name myserver.net wp.myserver.net;
return 404; # managed by Certbot
}
}
내 WordPress wp-config
<?php
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'admin' );
/** MySQL database password */
define( 'DB_PASSWORD', '*************' );
/** MySQL hostname */
define( 'DB_HOST', '192.168.1.34' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
/**#@-*/
$table_prefix = 'wp_';
define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
백엔드 서버의 NginX 구성
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
include /etc/nginx/conf.d/*.conf;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
root /var/www/wp;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 192.168.1.32:80;
server_name wp2.myserver.net;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/wp.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
try_files $uri $uri/ /index.php?$query_string;
}
index index.php;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}