Wordpress Rest API 역방향 프록시
워드프레스로 역방향 프록시를 설정하고 몇 개의 경로를 제외하려고 합니다.내 제외 규칙은 관리자, ...를 포함하여 작동하지만 /wp-json/에는 작동하지 않습니다..ht 액세스 때문인 것 같습니다.저는 개츠비js에서 사용하기 때문에 나머지 api 데이터를 반환하기 위해 워드프레스가 필요합니다.
저는 이것을 알아내려고 하루 종일 노력했습니다.어떤 이유로 /wp-json/이 404를 반환하고 사이트의 프런트 엔드 부분이 있는 netlify 서버로 프록시됩니다.제가 프록시 규칙을 모두 제거하면 wp-json이 작동합니다.
.htaccess에는 기본 wordpress 항목이 포함되어 있습니다.
다음은 가상 호스트의 붙여넣기 상자입니다. https://pastebin.com/vFh6hCkN
<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
Protocols h2 http/1.1
ServerName www.michaelharwinlaw.com
ServerAlias michaelharwinlaw.com
ServerAdmin webmaster@cyberserge.com
DocumentRoot /var/www/html/
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLProxyEngine on
ProxyPass /wp-admin/ !
ProxyPass /wp-login/ !
ProxyPass /wp-json/ !
ProxyPass /wp-content/plugins/ !
ProxyPass /wp-includes/ !
ProxyPassMatch .*\.xml !
ProxyPass / https://stag.michaelharwinlaw.com/
ProxyPassReverse / https://stag.michaelharwinlaw.com/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/mc-error.log
CustomLog ${APACHE_LOG_DIR}/mc-access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Include /var/www/html/wp-content/uploads/wpseo-redirects/.redirects
SSLCertificateFile /etc/letsencrypt/live/www.michaelharwinlaw.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.michaelharwinlaw.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
다음과 같은 이유로 작동하지 않습니다./wp-json
실제 파일 또는 디렉토리가 아닙니다. 읽기 없이는.htaccess
로컬 요청이 수신됩니다.404
not found
Apache가 원격 서버로 계속 요청을 전달하도록 응답합니다.
이 URL 다시 쓰기를 수정하려면 요청을 로컬로 보내야 합니다.index.php
.
교체하다ProxyPass /wp-json/ !
와 함께
ProxyPass /index.php !
ProxyPass /wp-json !
/wp-json
끝이 없는/
둘 다에 대한 요청을 처리하는 데 필요합니다.domain/wp-json
또는domain/wp-json/
.
존재하지 않는 다른 URL은 원격 서버에서 처리됩니다.
설명서에서 페이지 탐색이 작동하지 않음 섹션을 참조하십시오.
"이는 워드프레스가 생성하는 .htaccess 파일의 결함 때문입니다.이 문제를 해결하려면 .htaccess 파일의 내용을 삭제하고 다시 만드십시오.
- 제어판에서 관리 > 파일로 이동합니다(파일 편집에 대한 자세한 내용);
- .htaccess 파일에 대한 링크를 클릭하여 내용을 편집합니다.
- 파일의 내용을 복사하여 텍스트 편집기의 텍스트 파일에 붙여넣습니다.이는 .htaccess 파일에 리디렉션, 거부 또는 기타 핸디 htaccess 트릭에 대한 수동 항목이 있는 경우의 예방 조치입니다.
- .htaccess 파일에서 모든 내용을 삭제하고 Update File 버튼을 클릭합니다.
- 제어판에서 옵션 > Permalinks;로 이동합니다.
- Permalink Structure 업데이트 버튼을 클릭하여 Permalink에 대한 새 다시 쓰기 규칙을 새로 생성합니다.
- 이전에 끊어진 링크를 사용하여 결과를 테스트합니다.
- 수동 htaccess 항목을 파일에 다시 추가합니다(# BEGIN WordPress 행 앞이나 # END WordPress 행 뒤에 수동 htaccess 항목을 배치합니다).)"
언급URL : https://stackoverflow.com/questions/53507553/wordpress-rest-api-reverse-proxy
'code' 카테고리의 다른 글
URL로 인코딩된 양식 데이터가 잘못되었습니다. (0) | 2023.06.27 |
---|---|
범례 gg 그림 2.2 제거 (0) | 2023.06.27 |
UIS 검색 디스플레이 컨트롤러/UIS 검색 막대를 사용하여 NSFetched Results Controller(핵심 데이터)를 필터링하는 방법 (0) | 2023.06.27 |
과거에 임의의 커밋 두 개 사이에 커밋을 삽입하는 방법은 무엇입니까? (0) | 2023.06.27 |
C: 링크된 목록에서 노드를 해제하는 방법은 무엇입니까? (0) | 2023.06.27 |