본문 바로가기
Linux/for Hosting

[워드프레스] R3 [와일드카드]인증서 발급오류와 [사이트건강]cURL error 6

by aegypius 2022. 6. 20.
728x90
반응형

워드프레스 멀티사이트로 사이트를 제작해야 할 일이 생겼다.

네임서버와 웹서버의 설정을 마친 후에 Let's Encrypt의 인증서를 발급받는 과정에서 계속 오류가 발생한다. 전에도 가끔 이런 현상은 있었지만, 몇 번 다시 시도하거나 몇 시간 후에 다시 시도하면 인증서를 발급받을 수 있었다. 일단 인증서 발급은 다음으로 미루고 워드프레스를 설치한 후에 사이트의 건강상태를 확인해 보았다. 전에 없던 오류메시지 두 개가 보인다. 오류메시지를 저장하지는 못했지만 내용은 대략 아래와 같다.

  • (1) REST API 요청이 에러로 인해 실패했습니다. [The REST API request failed due to an error.]
    오류:cURL error 6:Could not resolve host:mydomain : .....

  • (2) 사이트에 대한 루프백 요청이 실패했습니다. [The loopback request to your site failed.]
    cURL error 6......

Rest API 오류는 예전에 포스팅했던 "REST API가 예상치 못했던 오류를 발견했습니다(404)"와는 조금 달랐다. 2021.04.09 - [Wordpress/etc] - The Rest API encountered an unexpected error

 

The Rest API encountered an unexpected error

레스트 API가 예상치 못한 오류를 발견했습니다. REST API는 워드프레스, 그리고 서버와 통신하는 다른 응용 프로그램으로 단방향입니다. 한 예는 블록 편집기 화면입니다. 이에 의존하여 보이

aegypius.tistory.com

 

두 개의 오류메시지에서 cURL error 6가 포함되어 있다. 워드프레스를 이제 막 새로 설치했기에 검색결과의 답변처럼 플러그인의 충돌로 인한 오류는 아닌것 같기도 하다.

아래의 글에서 해결책을 찾았다.
https://bobcares.com/blog/wordpress-curl-error-6-could-not-resolve-host/

 

WordPress cURL Error 6: Could not resolve host – Solve it now

Trying to find a solution for 'WordPress cURL Error 6: Could not resolve host '?The error whenever there is a problem with the DNS server.

bobcares.com

 

결론은...

/etc/resolv.conf 를 열어서...
nameserver 8.8.8.8
nameserver 8.8.4.4
를 추가하고 기존의 설정은 주석처리 하는 것이다. 이후 웹서버를 재시동 하면 문제가 해결된다고 한다. 결국 구글의 dns를 사용하라는 얘기다. 그런데...이 방법으로 해결이 되었다. 위의 글에서는 플러그인의 업데이트 중에 발생하는 DNS 오류라고 하는데......

그렇다면....서버에서 운영중인 자체 네임서버를 open DNS로 운영방식을 바꾸고 resolv.conf에 서버의 IP를 넣으면 어떻게 될지도 궁금하다. 하지만 이런 오류메시지가 자주 일어나는 일도 아니고...무엇보다도...

위의 방법대로 resolv.conf를 변경하여 오류를 해결 한 후에.....혹시나(?) 하는 마음에 서버를 (정말 오랜만에)리부팅하여 기존에 설정했던 네임서버로 다시 설정했는데도....더이상의 오류는 없었다. 아울러 Let'sEncrypt의 와일드카드 인증서의 발급도 오류없이 한 번에 진행되었다. DNS의 오류가 맞는것 같기는 한데.......뭔가 찜찜하다....-_-;

언제가 될 지는..모르겠지만...새로운 서버를 추가로 구축해야 하거나...서버를 이전할 일이 발생한다면....다시 테스트 해보고 싶다..... 윈도우PC 말고 리눅스 서버에서도 dns는 구글의 public dns를 사용하기 시작했다....-_-;


[추가]

위의 설정으로 상황이 종료되었다고 생각했는데...며칠 후 워드프레스 관리자페이지에서 멀티사이트 중의 하나를 선택하면 페이지를 찾을 수 없다는 오류가 종종 발생했다. 새로고침을 하거나 뒤로가기 후 다시 클릭하면 그제서야 페이지가 열리는 등 무언가 확실해 해결된 모습은 아니었다. 또한 워드프레스 관리자페이지의 '도구-'사이트 건강'을 보면, 이 글 맨 위의 (1)번 오류메시지(REST API 요청이 에러로 인해 실패했습니다.)는 사라졌지만 여전히 (2)번 오류(루프백 오류)는 간간이 발생했다. 둘 다 dns에 관련된 것은 분명한 것 같은데......특별히 할 수 있는게 없는거 같았지만.......우선은...

첫 째로 해당 도메인의 2차 네임서버를 구축했다. 

Could not resolve host....는 호스트(도메인)의 확인이 안되는 오류이니....혹시나 하는 마음에 해당 서브도메인에 대한 2차 네임서버까지 구축했다. 물론 외부 서버이다.  그리고....

둘 째로 /etc/resolv.conf를 편집불가 모드로 속성을 바꾸었다.

서버를 리부팅하면 resolv.conf의 값이 원래의 값으로 변경되었는데, 이는 NetworkManager가 아니라 dhclient-script에 의한 것이었다.(vultr의 vps. 서버 외부에서의 설정은 뭘 어떻게 해야 할지 막막하다. 네트워크 설정파일에 고정ip에 대한 설정값은 안보이는데도 ip를 제대로 할당받고 있으니 이부분을 내 마음대로 편집하기도 조금 망설여진다. 그래봐야 고정ip값과 dns1, dns2의 설정에 대한 추가편집으로 2~3줄이 충분하겠지만...)
/usr/sbin/dhclient/script를 열어서 make_resolv_conf를 주석처리하면 서버 리부팅시에 resolv.conf가 사라진다. -_-; 때문에 별도의 스크립트를 만들어서 서버가 리부팅 될 때마다 resolv.conf를 생성하려고 했는데.......이것 보다는...

chattr 명령어를 이용해서 수동으로 만든 resolv.conf를 '편집/삭제 불가모드'로 속성을 바꾸는 방법을 선택했다. 역시나 리부팅후에도 파일이 변경/삭제되지 않는다.

# chattr +i /etc/resolv.conf

lsattr명령으로 파일의 속성을 확인할 수 있으며, chattr명령으로 새로운 속성을 부여(+)하거나 제거(-)할 수 있다. 아무래도 옵션은 a(Append only)와 i(immutable)가 가장 많이 쓰일 듯 하다.

며칠 더 두고봐야 알겠지만, 앞으로 루프백 오류가 발생하지 않는다면, 2차네임서버의 설정 때문인지 아니면 resolv.conf의 변경설정 때문인지 다시 테스트를 해봐야 알 수 있을 것이다. 대략 일주일 정도 후에.....


[2022-07-03]

새로운 도메인으로 테스트 해봤는데 cURL error 6는 여전히 (그리고 간헐적으로) 발생한다. 대략 열흘 전에 수행한 테스트에서 resolv.conf에 구글의 퍼블릭 네임서버를 설정해서 해결했다는 글을 보고 따라했는데.....결과는...100% 완벽한 해결은 아니었다. 함께 작업했던 2차 네임서버의 구축도 결국 정답은 아니라는 얘기다. 아래의 링크를 참조했는데 대략 18개월 전에 Loopback address를 사용해서 해결 했다는 사례를 찾았다. centos가 아닌 osx 환경이지만 오류를 해결했다는 글을 보고 희망을 갖고 따라해봤다. resolv.conf의 최상단에 loopback address(127.0.0.1)를 넣고 network.service를 재시동 해보니 워드프레스의 건강상태에서 cURL error 6에 관련된 두 개의 오류 메시지가 사라졌다. 며칠 두고봐야 완벽한 해결이 된 것인지 확신할 수 있을 것이다.

LetsEncrypt의 R3 와일드카드 인증서의 발급과정에서 가끔씩 발생하는 오류는 네임서버의 설정과 관련이 있는 듯 하다. 정확한 원인은 모르겠지만 ZONE 파일을 작성할 때에 SOA 레코드와 NS 레코드의 설정 부분에서 origin(@)의 사용을 자제하고 FQDN으로 설정하면 인증서를 발급받는 과정에서 dns오류는 발생하지 않았다. 실제 사용중인 zone 파일의 일부는 아래와 같다.

$TTL       3H

@          IN     SOA  ns1.mydomain.tld.  root. ( 2020112201  1D  1H  1W  1H )
           IN     NS   ns1.mydomain.tld.
           IN     NS   ns2.mydomain.tld.
           IN     A    1xx.x6x.x9.x0x
ns1        IN     A    1xx.x6x.x9.x0x
ns2        IN     A    x.xxx.1x.x3x
~ 생략 ~

 

왜 이러한 오류가 발생하는 지에 대해서는 알 길이 없지만...기존의 워드프레스 5.x버전에서는 아무런 문제가 없었다. 6.0 버전으로 올라오면서 버그가 생긴 것이라고 생각했는데, 검색해보니 기존의 6.0이 나오기 이전부터 이런 문제를 겪고 있는 경우가 많있다. 또다시 일주일 정도 운영해 봐야 알 수 있겠지만....이것이 완벽한 해결책이 되기를 기대한다.....


[2022-07-04]

위의 수정과정을 거쳤음에도 하루만에 웹브라우저에 해당 도메인(워드프레스 멀티사이트로 구축한 웹사이트)을 입력하면 사이트를 찾을 수 없다는 오류메시지가 간헐적으로 발생하곤 했다. 크롬에서는 정상적이라도 파이어폭스나 엣지 등에서 발생하는 식인데, 새로고침(F5)를 몇 번 누르면 그제서야 사이트가 열리는 것이다. 워드프레스의 관리자 페이지에서 '도구 - 사이트건강'에서는 분명 cURL error 6 발생에 대한 오류보고는 없지만 DNS가 원활하지 않다는 것은 분명하다. 어제 생각한대로 Loopback address 대신에 운영중인 네임서버의 ip를 resolv.conf의 마지막에 추가해봤다. 그리고 모든 웹브라우저의 접속기록을 삭제한 후 윈도우의 DNS 캐시를 초기화했다. 그리고 서버도 리부팅했다. 

아주 깔끔하게 사이트가 열린다. 며칠 더 두고봐야 알겠지만 이제야 제대로 작동하는 느낌이다. 자체 네임서버를 OPEN DNS로 사용하지 않더라도 직접운영하는 도메인이 있다면 resolv.conf에 서버 자신의 ip주소는 등록해야겠다. (서버를 설정하면서 resolv.conf에 이렇게 신경을 써보기는 처음이다.)


[2022-07-06]

불과 3일 전만 하더라도 웹브라우저에 도메인을 입력하면 찾을 수 없다는 오류메시지가 간헐적으로 발생했었는데 지금은 완벽하게 사라졌다.(정확히 3일째 보이지 않는다) 하지만 cURL error 6를 동반한 loopback request 오류는 간헐적으로 보인다. 이 오류 리포팅이 있더라도 사이트를 운영하는데에는 그 어떤 사소한 문제도 발생하지 않기에....일단은..이쯤에서 마무리 하려고 한다.

1. 오래전부터 한글도메인을 많이 사용해봤기에, 단순히 한글도메인의 문제일 거라는 생각은 들지 않는다.

2. 한글도메인을 사용할 경우....상위 네임서버에서의 글루레코드가 제대로 등록이 안되어서 오류가 발생한 적은 있지만 그러한 경우 도메인 등록업체에서 바로(유선으로 연락을 한다면)피드백을 주기에...그런 문제도 아닌 거 같다.

3. 워드프레스 6.0으로 올린 후에 발생한 문제라서...이 또한 의심스럽다. 분명 워드프레스가 아닌 일반 웹사이트로 운영할 경우 아무런 문제가 없다. (사실 이제는 워드프레스로 제작했더라도 운영상의 문제는 사라지긴 했지만....)

4. 어찌되었건 DNS 문제인거 같으니.....한가할 때(?) 내 도메인에 대한 DNS 쿼리를 하나하나 추적해서 어디에서 문제가 발생하는지 찾아보는 것도 방법일 것이다..... (지금 상태로는 안나올 것 같다. -_-;)

아래는 이 이슈에 대해.......참고했던 내용이다....


https://stackoverflow.com/questions/54664844/curl-on-local-wordpress-site-returns-error-6-could-not-resolve-host

 

cURL on local WordPress site returns: Error 6 (Could not resolve host)

I have a local WordPress installation running at: https://catalogue3.test. Note that all .test domains should resolve to localhost, as I use Laravel valet. When I execute the following code in my

stackoverflow.com

 

https://github.com/laravel/valet/issues/736

 

cURL error 6: Could not resolve: site.test (Domain name not found) · Issue #736 · laravel/valet

I have a laravel app and a lumen api app both installed on my local machine. The laravel app uses the lumen app to get the data, so on my .env file the laravel app has its APP_DOMAIN=http://site.te...

github.com


[참고]
chattr의 man page

CHATTR(1)                                                                                                                                                            General Commands Manual                                                                                                                                                            CHATTR(1)



NAME
       chattr - change file attributes on a Linux file system

SYNOPSIS
       chattr [ -RVf ] [ -v version ] [ mode ] files...

DESCRIPTION
       chattr changes the file attributes on a Linux file system.

       The format of a symbolic mode is +-=[aAcCdDeijsStTu].

       The operator '+' causes the selected attributes to be added to the existing attributes of the files; '-' causes them to be removed; and '=' causes them to be the only attributes that the files have.

       The  letters  'aAcCdDeijsStTu' select the new attributes for the files: append only (a), no atime updates (A), compressed (c), no copy on write (C), no dump (d), synchronous directory updates (D), extent format (e), immutable (i), data journalling (j), secure deletion (s), synchronous updates (S), no tail-merging (t), top of directory hierarchy
       (T), and undeletable (u).

       The following attributes are read-only, and may be listed by lsattr(1) but not modified by chattr: compression error (E), huge file (h), indexed directory (I), inline data (N), compression raw access (X), and compressed dirty file (Z).

       Not all flags are supported or utilized by all filesystems; refer to filesystem-specific man pages such as btrfs(5), ext4(5), and xfs(5) for more filesystem-specific details.

OPTIONS
       -R     Recursively change attributes of directories and their contents.

       -V     Be verbose with chattr's output and print the program version.

       -f     Suppress most error messages.

       -v version
              Set the file's version/generation number.

ATTRIBUTES
       A file with the 'a' attribute set can only be open in append mode for writing.  Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

       When a file with the 'A' attribute set is accessed, its atime record is not modified.  This avoids a certain amount of disk I/O for laptop systems.

       A file with the 'c' attribute set is automatically compressed on the disk by the kernel.  A read from this file returns uncompressed data.  A write to this file compresses data before storing them on the disk.  Note: please make sure to read the bugs and limitations section at the end of this document.

       A file with the 'C' attribute set will not be subject to copy-on-write updates.  This flag is only supported on file systems which perform copy-on-write.  (Note: For btrfs, the 'C' flag should be set on new or empty files.  If it is set on a file which already has data blocks, it is undefined when the blocks assigned to the file will  be  fully
       stable.  If the 'C' flag is set on a directory, it will have no effect on the directory, but new files created in that directory will the No_COW attribute.)

       A file with the 'd' attribute set is not candidate for backup when the dump(8) program is run.

       When a directory with the 'D' attribute set is modified, the changes are written synchronously on the disk; this is equivalent to the 'dirsync' mount option applied to a subset of the files.

       The 'e' attribute indicates that the file is using extents for mapping the blocks on disk.  It may not be removed using chattr(1).

       The 'E' attribute is used by the experimental compression patches to indicate that a compressed file has a compression error.  It may not be set or reset using chattr(1), although it can be displayed by lsattr(1).

       The 'h' attribute indicates the file is storing its blocks in units of the filesystem blocksize instead of in units of sectors, and means that the file is (or at one time was) larger than 2TB.  It may not be set or reset using chattr(1), although it can be displayed by lsattr(1).

       A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.  Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

       The 'I' attribute is used by the htree code to indicate that a directory is being indexed using hashed trees.  It may not be set or reset using chattr(1), although it can be displayed by lsattr(1).

       A  file  with  the  'j'  attribute has all of its data written to the ext3 or ext4 journal before being written to the file itself, if the filesystem is mounted with the "data=ordered" or "data=writeback" options.  When the filesystem is mounted with the "data=journal" option all file data is already journalled and this attribute has no effect.
       Only the superuser or a process possessing the CAP_SYS_RESOURCE capability can set or clear this attribute.

       A file with the 'N' attribute set indicates that the file has data stored inline, within the inode itself. It may not be set or reset using chattr(1), although it can be displayed by lsattr(1).

       When a file with the 's' attribute set is deleted, its blocks are zeroed and written back to the disk.  Note: please make sure to read the bugs and limitations section at the end of this document.

       When a file with the 'S' attribute set is modified, the changes are written synchronously on the disk; this is equivalent to the 'sync' mount option applied to a subset of the files.

       A file with the 't' attribute will not have a partial block fragment at the end of the file merged with other files (for those filesystems which support tail-merging).  This is necessary for applications such as LILO which read the filesystem directly, and which don't understand tail-merged files.  Note: As of this writing,  the  ext2  or  ext3
       filesystems do not (yet, except in very experimental patches) support tail-merging.

       A  directory  with  the  'T' attribute will be deemed to be the top of directory hierarchies for the purposes of the Orlov block allocator.  This is a hint to the block allocator used by ext3 and ext4 that the subdirectories under this directory are not related, and thus should be spread apart for allocation purposes.   For example it is a very
       good idea to set the 'T' attribute on the /home directory, so that /home/john and /home/mary are placed into separate block groups.  For directories where this attribute is not set, the Orlov block allocator will try to group subdirectories closer together where possible.

       When a file with the 'u' attribute set is deleted, its contents are saved.  This allows the user to ask for its undeletion.  Note: please make sure to read the bugs and limitations section at the end of this document.

       The 'X' attribute is used by the experimental compression patches to indicate that the raw contents of a compressed file can be accessed directly.  It currently may not be set or reset using chattr(1), although it can be displayed by lsattr(1).

       The 'Z' attribute is used by the experimental compression patches to indicate a compressed file is dirty.  It may not be set or reset using chattr(1), although it can be displayed by lsattr(1).

AUTHOR
       chattr was written by Remy Card <Remy.Card@linux.org>.  It is currently being maintained by Theodore Ts'o <tytso@alum.mit.edu>.

BUGS AND LIMITATIONS
       The 'c', 's',  and 'u' attributes are not honored by the ext2, ext3, and ext4 filesystems as implemented in the current mainline Linux kernels.

       The 'j' option is only useful if the filesystem is mounted as ext3 or ext4.

       The 'D' option is only useful on Linux kernel 2.5.19 and later.

AVAILABILITY
       chattr is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net.

SEE ALSO
       lsattr(1), btrfs(5), ext4(5), xfs(5).



E2fsprogs version 1.42.9                                                                                                                                                  December 2013                                                                                                                                                                 CHATTR(1)
728x90
반응형

댓글