GVKun编程网logo

如何配置使用 WPML 的“每种语言不同的域”的 dockerized wordpress nginx?(wordpress用什么语言编写)

1

在这里,我们将给大家分享关于如何配置使用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用什么语言编写)

如何配置使用 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

  1. version: "3.3"
  2. services:
  3. XXXXweb-db:
  4. image: MysqL:5.7.26
  5. restart: always
  6. container_name: XXXXweb-db
  7. environment:
  8. MysqL_HOST: XXXXweb-db
  9. MysqL_DATABASE: ${DB_NAME}
  10. MysqL_USER: ${DB_USER}
  11. MysqL_PASSWORD: ${DB_PASS}
  12. MysqL_ROOT_PASSWORD: ${DB_ROOT_PASS}
  13. volumes:
  14. - ./data:/var/lib/MysqL:delegated
  15. - ./logs/MysqL:/var/log/MysqL:delegated
  16. - ./conf/MysqL.cnf:/etc/MysqL/my.cnf:delegated
  17. ports:
  18. - "3306:3306"
  19. expose:
  20. - 3306
  21. security_opt:
  22. - seccomp:unconfined
  23. XXXXweb-Nginx:
  24. image: Nginx:1.17.1-alpine
  25. restart: always
  26. ports:
  27. - "80:80"
  28. - "443:443"
  29. expose:
  30. - 80
  31. - 443
  32. volumes:
  33. - ./logs:/var/log/Nginx:delegated
  34. - ./conf/${Nginx_CONfig_NAME}:/etc/Nginx/Nginx.conf:delegated
  35. - ${CERT_PATH}:/etc/letsencrypt:delegated
  36. - ./:/wwwroot:delegated
  37. depends_on:
  38. - XXXXweb-db
  39. - XXXXweb-PHP
  40. logging:
  41. driver: "json-file"
  42. options:
  43. max-size: "100m"
  44. XXXXweb-PHP:
  45. image: PHP-XXXX
  46. restart: always
  47. ports:
  48. - "9000:9000"
  49. expose:
  50. - 9000
  51. volumes:
  52. - ./logs:/var/log:delegated
  53. - ./:/wwwroot:delegated
  54. healthcheck:
  55. test: ["CMD-SHELL","pidof PHP-fpm"]
  56. interval: 5s
  57. retries: 12
  58. logging:
  59. driver: "json-file"
  60. options:
  61. max-size: "100m"

Nginx-server.conf

  1. user Nginx;
  2. worker_processes 1;
  3. error_log /var/log/Nginx/error.log warn;
  4. pid /var/run/Nginx.pid;
  5. events { worker_connections 1024; }
  6. http {
  7. include /etc/Nginx/mime.types;
  8. default_type application/octet-stream;
  9. log_format main ''$http_x_forwarded_for - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'';
  10. access_log on;
  11. sendfile on;
  12. keepalive_timeout 65;
  13. client_max_body_size 100M;
  14. server {
  15. listen 80;
  16. server_name cool.XXXXXX.com;
  17. return 301 https://cool.XXXXXX.com$request_uri;
  18. }
  19. server {
  20. listen [::]:443 ssl ipv6only=on; # managed by Certbot
  21. listen 443 ssl; # managed by Certbot
  22. ssl_certificate /etc/letsencrypt/live/cool.XXXXXX.com/fullchain.pem; # managed by Certbot
  23. ssl_certificate_key /etc/letsencrypt/live/cool.XXXXXX.com/privkey.pem; # managed by Certbot
  24. ## Your website name goes here.
  25. server_name cool.XXXXXX.com;
  26. ## Your only path reference.
  27. root /wwwroot;
  28. ## This should be in your http block and if it is,it''s not needed here.
  29. index index.PHP;
  30. location = /favicon.ico {
  31. log_not_found off;
  32. access_log off;
  33. }
  34. location = /robots.txt {
  35. allow all;
  36. log_not_found off;
  37. access_log off;
  38. }
  39. location / {
  40. # This is cool because no PHP is touched for static content.
  41. # include the "?$args" part so non-default permalinks doesn''t break when using query string
  42. try_files $uri $uri/ /index.PHP?$args;
  43. }
  44. location ~ \\.PHP$ {
  45. try_files $uri =404;
  46. fastcgi_split_path_info ^(.+\\.PHP)(/.+)$;
  47. fastcgi_pass XXXXweb-PHP:9000;
  48. fastcgi_index index.PHP;
  49. include fastcgi_params;
  50. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  51. fastcgi_param PATH_INFO $fastcgi_path_info;
  52. }
  53. location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {
  54. expires max;
  55. log_not_found off;
  56. }
  57. }
  58. }

添加后

  1. server {
  2. listen 80;
  3. server_name jp-cool.XXXXXX.com;
  4. return 301 https://jp-cool.XXXXXX.com$request_uri;
  5. }

它适用于 http 不安全的连接。

但是,在我添加了 jp-cool.XXXXXX.comcool.XXXXXX.com 重复部分后,只有其中一个可以工作。

当我设置“每种语言的不同域”时,我在 WPML 面板上看到了 invalid

没有docker,我可以在本地Nginx中设置不同的域/etc/Nginx/site-available

但我无法使用 dockerized Nginx 进行设置。

解决方法

如果您没有通配符证书,您唯一的选择是为每个证书复制服务器块。您可以这样做:

  1. server {
  2. # this part changes per certificate
  3. ssl_certificate /etc/letsencrypt/live/cool.XXXXXX.com/fullchain.pem; # managed by Certbot
  4. ssl_certificate_key /etc/letsencrypt/live/cool.XXXXXX.com/privkey.pem; # managed by Certbot
  5. server_name cool.XXXXXX.com;
  6. include common;
  7. }
  8. server {
  9. # this part changes per certificate
  10. ssl_certificate /etc/letsencrypt/live/jp-cool.XXXXXX.com/fullchain.pem; # managed by Certbot
  11. ssl_certificate_key /etc/letsencrypt/live/jp-cool.XXXXXX.com/privkey.pem;
  12. server_name jp-cool.XXXXXX.com;
  13. include common;
  14. }

为了遵循 DRY 原则,将服务器块的其余部分放入一个单独的文件中。我已经使用“common”作为该文件的名称,您需要将它放在 /etc/nginx/ 中,否则您必须更改上面块中的路径。 /etc/nginx/common

  1. listen [::]:443 ssl ipv6only=on; # managed by Certbot
  2. listen 443 ssl; # managed by Certbot
  3. root /wwwroot;
  4. ## This should be in your http block and if it is,it''s not needed here.
  5. index index.php;
  6. location = /favicon.ico {
  7. log_not_found off;
  8. access_log off;
  9. }
  10. location = /robots.txt {
  11. allow all;
  12. log_not_found off;
  13. access_log off;
  14. }
  15. location / {
  16. # This is cool because no php is touched for static content.
  17. # include the "?$args" part so non-default permalinks doesn''t break when using query string
  18. try_files $uri $uri/ /index.php?$args;
  19. }
  20. location ~ \\.php$ {
  21. try_files $uri =404;
  22. fastcgi_split_path_info ^(.+\\.php)(/.+)$;
  23. fastcgi_pass XXXXweb-php:9000;
  24. fastcgi_index index.php;
  25. include fastcgi_params;
  26. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  27. fastcgi_param PATH_INFO $fastcgi_path_info;
  28. }
  29. location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {
  30. expires max;
  31. log_not_found off;
  32. }

您也可以使用一台服务器进行 HTTPS 重定向:

  1. server {
  2. listen 80;
  3. server_name cool.XXXXXX.com;
  4. server_name jp-cool.XXXXXX.com;
  5. return 301 https://$host$request_uri;
  6. }

ACF 选择在 WPML 中注册

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'' );
    }
}

然后扫描您的主题/插件以查找字符串:

  1. 在管理仪表板中,转到 WPML > 主题和插件本地化
  2. 选择主题或插件,然后点击扫描。
  3. 扫描完成后,您应该能够在“字符串翻译”页面上找到字符串。

文档:

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 一起使用

如何解决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
            )

还有 DockerfileAPP1

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 文件)

如何解决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:连接到上游时连接被拒绝

如何解决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:连接到上游时连接被拒绝的相关信息,请在本站查询。

本文标签: