在这里,我们将给大家分享关于如何配置使用WPML的“每种语言不同的域”的dockerizedwordpressnginx?的知识,让您更了解wordpress用什么语言编写的本质,同时也会涉及到如何更
在这里,我们将给大家分享关于如何配置使用 WPML 的“每种语言不同的域”的 dockerized wordpress nginx?的知识,让您更了解wordpress用什么语言编写的本质,同时也会涉及到如何更有效地ACF 选择在 WPML 中注册、Dockerized Flask 不能与 dockerized neo4j 一起使用、Dockerized wordpress 前端/管理未完全加载(无法加载样式表和 JS 文件)、Dockerized Wordpress/nginx:连接到上游时连接被拒绝的内容。
本文目录一览:- 如何配置使用 WPML 的“每种语言不同的域”的 dockerized wordpress nginx?(wordpress用什么语言编写)
- ACF 选择在 WPML 中注册
- Dockerized Flask 不能与 dockerized neo4j 一起使用
- Dockerized wordpress 前端/管理未完全加载(无法加载样式表和 JS 文件)
- Dockerized Wordpress/nginx:连接到上游时连接被拒绝
如何配置使用 WPML 的“每种语言不同的域”的 dockerized wordpress nginx?(wordpress用什么语言编写)
如何解决如何配置使用 WPML 的“每种语言不同的域”的 dockerized wordpress nginx?
现在这是一个 cool.XXXXXX.com
正在使用的域。
我想使用名为 jp-cool.XXXXXX.com
的域显示我的日语版本
我用 letencrypt 设置了 SSL
certbot certonly --standalone -d jp-cool.XXXXXX.com --staple-ocsp -m root@jp-cool.XXXXXX.com --agree-tos
docker-compose.yml
version: "3.3"
services:
XXXXweb-db:
image: MysqL:5.7.26
restart: always
container_name: XXXXweb-db
environment:
MysqL_HOST: XXXXweb-db
MysqL_DATABASE: ${DB_NAME}
MysqL_USER: ${DB_USER}
MysqL_PASSWORD: ${DB_PASS}
MysqL_ROOT_PASSWORD: ${DB_ROOT_PASS}
volumes:
- ./data:/var/lib/MysqL:delegated
- ./logs/MysqL:/var/log/MysqL:delegated
- ./conf/MysqL.cnf:/etc/MysqL/my.cnf:delegated
ports:
- "3306:3306"
expose:
- 3306
security_opt:
- seccomp:unconfined
XXXXweb-Nginx:
image: Nginx:1.17.1-alpine
restart: always
ports:
- "80:80"
- "443:443"
expose:
- 80
- 443
volumes:
- ./logs:/var/log/Nginx:delegated
- ./conf/${Nginx_CONfig_NAME}:/etc/Nginx/Nginx.conf:delegated
- ${CERT_PATH}:/etc/letsencrypt:delegated
- ./:/wwwroot:delegated
depends_on:
- XXXXweb-db
- XXXXweb-PHP
logging:
driver: "json-file"
options:
max-size: "100m"
XXXXweb-PHP:
image: PHP-XXXX
restart: always
ports:
- "9000:9000"
expose:
- 9000
volumes:
- ./logs:/var/log:delegated
- ./:/wwwroot:delegated
healthcheck:
test: ["CMD-SHELL","pidof PHP-fpm"]
interval: 5s
retries: 12
logging:
driver: "json-file"
options:
max-size: "100m"
Nginx-server.conf
user Nginx;
worker_processes 1;
error_log /var/log/Nginx/error.log warn;
pid /var/run/Nginx.pid;
events { worker_connections 1024; }
http {
include /etc/Nginx/mime.types;
default_type application/octet-stream;
log_format main ''$http_x_forwarded_for - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'';
access_log on;
sendfile on;
keepalive_timeout 65;
client_max_body_size 100M;
server {
listen 80;
server_name cool.XXXXXX.com;
return 301 https://cool.XXXXXX.com$request_uri;
}
server {
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/cool.XXXXXX.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/cool.XXXXXX.com/privkey.pem; # managed by Certbot
## Your website name goes here.
server_name cool.XXXXXX.com;
## Your only path reference.
root /wwwroot;
## This should be in your http block and if it is,it''s not needed here.
index index.PHP;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no PHP is touched for static content.
# include the "?$args" part so non-default permalinks doesn''t break when using query string
try_files $uri $uri/ /index.PHP?$args;
}
location ~ \\.PHP$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\\.PHP)(/.+)$;
fastcgi_pass XXXXweb-PHP:9000;
fastcgi_index index.PHP;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
}
添加后
server {
listen 80;
server_name jp-cool.XXXXXX.com;
return 301 https://jp-cool.XXXXXX.com$request_uri;
}
它适用于 http
不安全的连接。
但是,在我添加了 jp-cool.XXXXXX.com
的 cool.XXXXXX.com
重复部分后,只有其中一个可以工作。
当我设置“每种语言的不同域”时,我在 WPML 面板上看到了 invalid
。
没有docker,我可以在本地Nginx中设置不同的域/etc/Nginx/site-available
但我无法使用 dockerized Nginx 进行设置。
解决方法
如果您没有通配符证书,您唯一的选择是为每个证书复制服务器块。您可以这样做:
server {
# this part changes per certificate
ssl_certificate /etc/letsencrypt/live/cool.XXXXXX.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/cool.XXXXXX.com/privkey.pem; # managed by Certbot
server_name cool.XXXXXX.com;
include common;
}
server {
# this part changes per certificate
ssl_certificate /etc/letsencrypt/live/jp-cool.XXXXXX.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/jp-cool.XXXXXX.com/privkey.pem;
server_name jp-cool.XXXXXX.com;
include common;
}
为了遵循 DRY 原则,将服务器块的其余部分放入一个单独的文件中。我已经使用“common”作为该文件的名称,您需要将它放在 /etc/nginx/
中,否则您必须更改上面块中的路径。 /etc/nginx/common
:
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
root /wwwroot;
## This should be in your http block and if it is,it''s not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn''t break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \\.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\\.php)(/.+)$;
fastcgi_pass XXXXweb-php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
您也可以使用一台服务器进行 HTTPS 重定向:
server {
listen 80;
server_name cool.XXXXXX.com;
server_name jp-cool.XXXXXX.com;
return 301 https://$host$request_uri;
}
ACF 选择在 WPML 中注册
如何解决ACF 选择在 WPML 中注册
由于 WPML 没有提供翻译 [choices]
字段的解决方案,我想添加一个自定义函数以在 WPML 中注册它,但是我不是 PHP 中的明星,但我有以下但它没有在 WPML 字符串翻译中注册它:
$field = get_field_object( ''type_of_property'' ); // acf field with choices
if (!empty($field[''choices''])) {
foreach( $field[''choices''] as $choice ){
do_action( ''wpml_register_single_string'',''ACF Domain'',''name''.$choice,$choice );
$acflabel= apply_filters( ''wpml_translate_single_string'',$choice,NULL );
echo '' - '' . $acflabel;
}
}
上述方法是否朝着正确的方向发展,还是我需要调用 type_of_property
字段中的所有选项?
解决方法
我相信你应该能够做到这一点:
$field = get_field_object( ''type_of_property'' );
if ( !empty( $field[''choices''] ) ) {
foreach( $field[''choices''] as $choice ){
echo '' - '' . __( $choice,''ACF Domain'' );
}
}
然后扫描您的主题/插件以查找字符串:
- 在管理仪表板中,转到 WPML > 主题和插件本地化
- 选择主题或插件,然后点击扫描。
- 扫描完成后,您应该能够在“字符串翻译”页面上找到字符串。
文档:
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/#:~:text=To%20scan%20for%20hard%2Dcoded%20strings%3A
Dockerized Flask 不能与 dockerized neo4j 一起使用
如何解决Dockerized Flask 不能与 dockerized neo4j 一起使用
我试图在一个容器中运行 neo4j,在另一个容器中运行一个 Flask 应用程序。我有一个 docker.compose.yml
像这样:
version: ''3''
services:
app1:
container_name: app1
image: python:3.7.3-slim
build: ./APP1/
volumes:
- ./APP1/:/usr/src/app/
environment:
PORT: 5000
FLASK_DEBUG: 1
ports:
- 5000:5000
tty: true
neo4:
container_name: neo4j
image: neo4j:3.5
environment:
- NEO4J_dbms_memory_pagecache_size=2G
- dbms_connector_bolt_tls__level=OPTIONAL
- NEO4J_dbms_memory_heap_max__size=3500M
- NEO4J_AUTH=user/pwd
volumes:
- $HOME/neo4j/data:/data
- $HOME/neo4j/logs:/logs
- $HOME/neo4j/import:/import
- $HOME/neo4j/plugins:/plugins
ports:
- 7474:7474
- 7687:7687
我的app.py
:
app = Flask(__name__)
if __name__ == ''__main__'':
app.run(host="0.0.0.0",port=5000,debug=True
)
还有 Dockerfile
的 APP1
:
FROM python:3.7.3-slim
RUN mkdir /usr/src/app/
copY . /usr/src/app/
workdir /usr/src/app/
EXPOSE 5000
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
ENTRYPOINT ["python3","app.py"]
然后我使用 docker-compose up
来执行。当我通过浏览器访问 neo4j 时,我可以正常访问(http://localhost:7474/),但对于 Flask 应用程序,我无权访问(http://0.0.0.0:5000/)。我的配置哪里出错了?
解决方法
http://0.0.0.0:5000
并不意味着 localhost
,而是所有网络接口。所以你无法联系到 localhost
。
我解决了它,这实际上是一个愚蠢的错误,但我猜可能会发生在其他人身上...... 在 docker-compose.yml
中:
build: ./APP1/
需要用引号引起来,所以:
build: ''./APP1/''
Dockerized wordpress 前端/管理未完全加载(无法加载样式表和 JS 文件)
如何解决Dockerized wordpress 前端/管理未完全加载(无法加载样式表和 JS 文件)?
我已经使用 this 方法部署了一个简单的 wordpress 网站。从服务器上看,一切正常,所有容器和服务都已启动并正在运行,管理面板和网站都可以访问。没有 SSL 问题,certbot
检查以 code 0
退出。
不过,似乎有些 .css
和 .js
文件没有加载,导致网站部分加载,插件和主题无法正常工作。
这是docker-compose.yml
:
version: ''3''
services:
db:
image: MysqL:8.0
container_name: db
restart: unless-stopped
env_file: .env
environment:
- MysqL_DATABASE=wordpress
volumes:
- dbdata:/var/lib/MysqL
- ./backup:/home/backup
command: ''--default-authentication-plugin=MysqL_native_password''
networks:
- app-network
wordpress:
depends_on:
- db
image: wordpress:5.5.1-PHP7.4-fpm-alpine
container_name: wordpress
restart: unless-stopped
env_file: .env
environment:
- wordpress_DB_HOST=db:3306
- wordpress_DB_USER=$MysqL_USER
- wordpress_DB_PASSWORD=$MysqL_PASSWORD
- wordpress_DB_NAME=wordpress
volumes:
- wordpress:/var/www/html
- ./themes:/var/www/html/wp-content/themes
- ./plugins:/var/www/html/wp-content/plugins
- ./backup:/home/backup
networks:
- app-network
webserver:
depends_on:
- wordpress
image: Nginx:1.18.0-alpine
container_name: webserver
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- wordpress:/var/www/html
- ./Nginx-conf:/etc/Nginx/conf.d
- certbot-etc:/etc/letsencrypt
networks:
- app-network
certbot:
depends_on:
- webserver
image: certbot/certbot
container_name: certbot
volumes:
- certbot-etc:/etc/letsencrypt
- wordpress:/var/www/html
volumes:
certbot-etc:
wordpress:
dbdata:
networks:
app-network:
driver: bridge
和Nginx.conf
:
server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;
location ~ /.well-kNown/acme-challenge {
allow all;
root /var/www/html;
}
location / {
rewrite ^ https://$host$request_uri? permanent;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name domain.com www.domain.com;
index index.PHP index.html index.htm;
root /var/www/html;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
include /etc/Nginx/conf.d/options-ssl-Nginx.conf;
#gzip on
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/RSS+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_types *;
client_max_body_size 256M;
add_header x-frame-options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: ''unsafe-eval'' ''unsafe-inline''" always;
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# enable strict transport security only if you understand the implications
location / {
try_files $uri $uri/ /index.PHP$is_args$args;
include /etc/Nginx/mime.types;
}
location ~ \.PHP$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
fastcgi_pass wordpress:9000;
fastcgi_index index.PHP;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off; access_log off;
}
location = /robots.txt {
log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
}
即使是调试模式也没有显示任何错误。从检查控制台,它显示以下内容:
拒绝应用来自“https://DOMAIN/wp-content/plugins/updraftplus/css/tether-shepherd/shepherd-theme-arrows-plain-buttons.min.css?ver=1.16.56”的样式,因为其 MIME 类型 (''text/html'') 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查。
获取 https://DOMAIN/wp-content/plugins/updraftplus/includes/tether-shepherd/shepherd.min.js?ver=1.16.56 net::ERR_ABORTED 404
感谢您的帮助。
解决方法
虽然我从头开始重新部署整个项目,但我认为问题是由于在 docker-compose.yml
中安装了主题、插件和备份文件夹,而没有获得正确的许可。因为我在新部署中省略了这些挂载,一切顺利。
Dockerized Wordpress/nginx:连接到上游时连接被拒绝
如何解决Dockerized Wordpress/nginx:连接到上游时连接被拒绝?
我在 Docker 上设置使用 Nginx 代理的 wordpress 时遇到了困难。我设法解决了大多数问题,例如重写和数据库导入,但是当访问 WP 管理登录面板时,它工作正常,但是一旦我登录,我得到 502 Bad Gateway,并且 Docker 的 Nginx 日志说:
2021/07/20 14:01:25 [error] 24#24: *346 connect() Failed (111: Connection refused) while connecting to upstream,client: 10.5.0.130,server: $host,request: "POST /example_com/wp-login.PHP HTTP/1.1",upstream: "https://172.18.0.4:443/wp-admin/",host: "docker-node-01",referrer: "https://docker-node-01/example_com/wp-login.PHP"
我的docker-compose.yml
:
networks:
main:
driver: bridge
services:
wordpress-Nginx:
image: Nginx
container_name: wordpress-Nginx
hostname: wordpress-Nginx
restart: always
ports:
- 80:80
- 443:443
networks:
- main
extra_hosts:
- "example.com www.example.com:172.18.0.4"
volumes:
- ./data/Nginx_conf:/etc/Nginx/conf.d
- ./data/Nginx_ssl:/etc/Nginx/ssl
wordpress-MysqL:
image: MysqL
container_name: wordpress-MysqL
hostname: wordpress-MysqL
restart: always
networks:
- main
env_file:
- ./etc/wordpress-MysqL.env
volumes:
- ./data/dbinit:/docker-entrypoint-initdb.d
- ./data/dbdata:/var/lib/MysqL
example.com:
image: wordpress
container_name: example.com
depends_on:
- wordpress-MysqL
hostname: example.com
restart: always
networks:
- main
extra_hosts:
- "example.com www.example.com:127.0.1.1"
env_file:
- ./etc/wordpress-main.env
volumes:
- ./data/wp_plugins:/var/www/html/wp-content/plugins
- ./data/wp_themes:/var/www/html/wp-content/themes
- ./data/wp_uploads:/var/www/html/wp-content/uploads
我的Nginx配置:
server {
listen 443 ssl;
server_name $host;
resolver 127.0.0.11;
ssl_certificate /etc/Nginx/ssl/default.crt;
ssl_certificate_key /etc/Nginx/ssl/default.key;
location /example_com/ {
sub_filter ''www.example.com'' ''$host/example_com'';
sub_filter ''example.com'' ''$host/example_com'';
sub_filter_once off;
proxy_pass http://example.com/;
proxy_redirect http://example.com/ example_com/;
proxy_set_header Host example.com;
proxy_set_header Accept-Encoding '''';
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;
proxy_cookie_path / /;
proxy_intercept_errors on;
error_page 301 302 307 = @handle_redirects;
# no cache
proxy_no_cache 1;
proxy_cache_bypass 1;
}
location @handle_redirects {
set $saved_redirect_location ''$upstream_http_location'';
proxy_pass $saved_redirect_location;
}
location ~ ^([^.\?]*[^/])$ {
try_files $uri @addslash;
}
location @addslash {
return 301 $uri/;
}
location / {
try_files $uri $uri/ /index.PHP$is_args$args;
}
}
在类似问题中,我找不到适合我的解决方案。就其价值而言,我认为这是 wordpress 的 PHP 而非 Nginx 配置本身的问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
我们今天的关于如何配置使用 WPML 的“每种语言不同的域”的 dockerized wordpress nginx?和wordpress用什么语言编写的分享已经告一段落,感谢您的关注,如果您想了解更多关于ACF 选择在 WPML 中注册、Dockerized Flask 不能与 dockerized neo4j 一起使用、Dockerized wordpress 前端/管理未完全加载(无法加载样式表和 JS 文件)、Dockerized Wordpress/nginx:连接到上游时连接被拒绝的相关信息,请在本站查询。
本文标签: