워드프레스 멀티 사이트 + AWS + HTTPS 적용 시, 쿠키 오류를 해결해 보자

IT/Wordpress 2024. 9. 22. 01:02

bitanmi wordpress의 멀티사이트 이미지를 사용하여 AWS에서 국문 사이트와 영문 사이트를 개발

https://docs.bitnami.com/aws/apps/wordpress-multisite/

 

Bitnami package for WordPress Multisite for AWS Cloud

 

docs.bitnami.com

 

 

메인 사이트는 영문 사이트이고, 서브 도메인을 사용하여 국문 사이트를 구성

영문 사이트: domain.com

국문 사이트: sub.domain.com

 

멀티사이트에서 도메인 변경은 데이터베이스에서 아래 데이터베이스 테이블에서 사이트 URL을 변경

https://wpengine.com/support/what-is-wordpress-multisite/#Main_Site

 

WordPress Multisite - Support Center

Learn about WordPress Multisite on WP Engine: When to use it, how to convert, custom domain mapping, and deployment best practices.

wpengine.com

 

wp_options home Yes  
wp_options siteurl Yes  
wp_site domain No  
wp_sitemeta siteurl Yes Include trailing slash
wp_blogs domain No Update all rows
wp_#_options siteurl Yes Update all # options tables
wp_#_options home Yes Update all # options tables

 

대부분의 멀티 사이트에서는 별다른 문제가 없으나, 해당 사이트의 경우, 테마 플러그인 중, 캐시/보안 플러그인으로 인한 관리자 페이지 로그인 시, 쿠키 차단 오류가 발생

 

쿠키 오류 해결을 위해, 아래 값을 추가함

wp-config.php

define('COOKIE_DOMAIN', 'domain.com');

define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
    $_SERVER['HTTPS'] = 'on';
}

 

일부 경우에서는 https로의 쿠키 발행에 실패하는 것으로 추정함

 

어드민 페이지의 로그인 결과가 실패라고 하더라도, 메인 페이지에서는 로그인에 성공함

서버는 로그인한 것으로 인식하고 있으나, 브라우저에서의 쿠키 사용이 안되는 경우로 추정

메인 페이지로 돌아간 후, 상단의 어드민 바에서 관리자 페이지로 접속