Конфигурация лака для мультисайта на nginx & Centos 7 - PullRequest
0 голосов
/ 31 октября 2019

Я хочу запустить свой сайт WordPress как блог моего сайта magento 2

Мой сайт magento 2 уже работает и работает, но когда я добавляю свой файл конфигурации WordPress nginx и перезагружаю nginx,Веб-сайт magento 2 больше не загружается: ошибка 503 Не удалось получить внутреннюю загрузку

ОС CentOS 7

Я должен добавить, что я использую расширение fishpeg для интеграции wordpress в magento 2, однако это не таксвязанные с этой проблемой

, но каталог wordpress находится внутри каталога magento ... / public_html / pub / wp

здесь находится конфигурация wordpress для nginx

server {
    server_name mydomain.com www.mydomain.com;
        root /.../.../public_html/pub/wp;


    # Certificate
        listen 443 ssl http2;
        ssl_certificate /etc/ca-certificates/crt.crt;
        ssl_certificate_key /etc/ca-certificates/key.key;

        client_max_body_size 100M;
        location /wp-admin/ {
        index index.php;
        try_files $uri $uri/ /index.php$args;
    }

location / {
        root /home/elysium/public_html/wp;
        index index.php index.html index.htm index.nginx-debian.html;
        try_files $uri $uri /index.php?q=$uri&$args;


  }
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        # POST requests and urls with a query string should always go to PHP
        if ($request_method = POST) {
                set $no_cache 1;
        }
        if ($query_string != "") {
                set $no_cache 1;
        }

        # Don't cache uris containing the following segments
        if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-$
        set $no_cache 1;
        }

        # Don't use the cache for logged in users or recent commenters
        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                set $no_cache 1;
        }
        fastcgi_pass_header Set-Cookie;
        fastcgi_pass_header Cookie;
        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED    $document_root$fastcgi_path_info;
        fastcgi_intercept_errors on;
        include fastcgi_params;
        fastcgi_cache_valid 404 60m;
        fastcgi_cache_valid 200 60m;
        fastcgi_max_temp_file_size 4m;
        fastcgi_cache_use_stale updating;
    }
        location ~* \.(ico|jpg|webp|jpeg|gif|css|png|js|ico|bmp|zip|woff|svg|eot|otf||woff2|ttf|ogg)$ {
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "public";
        expires 14d;
    }
        location ~* \.(php|html)$ {
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "public";
        expires 14d;
    }
}
server {
    listen 80 http2;
    server_name mydomain.com www.mydomain.com;
    # return 404; # managed by Certbot
        root /.../.../public_html/pub/wp;


}

magento2 Конфигурация nginx

   ## Maps config file
   include conf_m2/maps.conf;

   ## Proxy server to terminate ssl
  server {
   listen 443 ssl http2;
   server_name www.mydomain.com mydomain.com;
#
   ## Rewrite hardcoded http links
  sub_filter 'http://'  'https://';
  sub_filter_once off;
  ssl_certificate     /root/cert.cert;
  ssl_certificate_key /root/cert.key;
location /wp/ {
  index index.html index.php;
  try_files $uri $uri/ /wp/index.php?q=$uri&args;


#    location /wp/wp-admin/ {
#    index index.php;
#    try_files $uri $uri/ /index.php$args;
#    }

  location ~ \.php$ {
    #proxy_pass  http://127.0.0.1:8081;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  /wp/index.php;
    include        fastcgi.conf;
  }
   ## Proxy-pass to Varnish
location / {
    proxy_pass  http://127.0.0.1:8081;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header Host $host;
    proxy_set_header X-Scheme https;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-Port 443;
    proxy_set_header X-Secure on;
    proxy_set_header Accept-Encoding "";
    proxy_set_header Connection "";
    proxy_http_version 1.1;
    proxy_read_timeout 7200s;
    proxy_send_timeout 7200s;
  }
 }


  server {
   listen 80 reuseport;
 #listen 443 ssl http2 reuseport;
   server_name www.mydomain.com mydomain.com;

   access_log  /var/log/nginx/access.log  main;
   error_log   /var/log/nginx/error.log  error;

   if ($bad_client) { return 403; }

   ## Set Magento root folder
   set $MAGE_ROOT /.../.../public_html;
   ## Set main public directory /pub
   root $MAGE_ROOT/pub;

   ## SSL CONFIGURATION
  #ssl_certificate     /root/cert.cert;
  #ssl_certificate_key /root/cert.key;

   ## Nginx and php-fpm status
   include conf_m2/status.conf;

   ## Server maintenance block.
#  include conf_m2/maintenance.conf;
 ## Magento Setup Tool
   include conf_m2/setup.conf;

   ## Deny all internal locations also default phpmyadmin
   location ~ ^/(app|generated|lib|bin|var|tmp|phpserver|vendor|magento_version|php[mM]y[aA]dmin|pma)/? {
     deny all;
   }

   location / {
     try_files $uri $uri/ /index.php$is_args$args;
   }


   ## Error log/page
#  include conf_m2/error_page.conf;

   ## Static location
   include conf_m2/assets.conf;

   ## Protect extra directories
   include conf_m2/extra_protect.conf;

   ## Process php files (strict rule, define files to be executed)
   location ~ (index|health_check|get|static|report|UTcosiBPInuS_opcache_gui|404|503)\.php$ {
     try_files $uri =404;
#    fastcgi_intercept_errors on;
     include conf_m2/php_backend.conf;

     ## Enable Magento profiler
#    fastcgi_param   MAGE_PROFILER html;

     ## Store code with multi domain
#    fastcgi_param   MAGE_RUN_CODE $MAGE_RUN_CODE;
#    fastcgi_param   MAGE_RUN_TYPE $MAGE_RUN_TYPE;

     ## Enable POST logging in admin
#    if ($request_method = POST) {set $adminpost A;}
#    if ($request_uri ~* "/ADMIN_PLACEHOLDER/") {set $adminpost "${adminpost}B";}
#    if ($adminpost = AB) { access_log /var/log/nginx/admin_post.log adminpost;}
   }

   ## Block other undefined php files, possible injections and random malware hooks.
   location ~* \.php$ {
     return 404;
   }
  }

лак.парамс

# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings

# Set this to 1 to make systemd reload try to switch VCL without restart.
RELOAD_VCL=1

# Main configuration file. You probably want to change it.
VARNISH_VCL_CONF=/etc/varnish/default.vcl

# Default address and port to bind to. Blank address means all IPv4
# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted
# quad, or an IPv6 address in brackets.
VARNISH_LISTEN_ADDRESS=127.0.0.1
VARNISH_LISTEN_PORT=8081

# Admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082

# Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret

# Backend storage specification, see Storage Types in the varnishd(5)
# man page for details.
VARNISH_STORAGE="malloc,1G"

# User and group for the varnishd worker processes
VARNISH_USER=varnish
VARNISH_GROUP=varnish

# Other options, see the man page varnishd(1)
DAEMON_OPTS="-p thread_pool_min=200 \
        -p thread_pool_max=4000 \
        -p thread_pool_add_delay=2 \
        -p cli_timeout=25 \
        -p cli_buffer=26384 \
        -p syslog_cli_traffic=off \
        -p feature=+esi_ignore_https \
        -p feature=+esi_disable_xml_check,+esi_ignore_other_elements \
        -p vcc_allow_inline_c=on \
        -p timeout_linger=100"

лак по умолчанию.vcl

#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.

# Marker to tell the VCL compiler that this VCL has been adapted to the
# new 4.0 format.
vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "127.0.0.1";
    .port = "80";
}
backend blog {
      .host = "127.0.0.1";
      .port = "8010";
 }
sub vcl_recv {
    if (req.http.host == "blog.mydomain.com") {
#        #You will need the following line only if your backend has multiple virtual host names
        set req.backend_hint=blog;
        return (pass);
        #
        #                                    }
}
}
#sub vcl_recv {
    # Happens before we check if we have this in cache already.
    #
    # Typically you clean up the request here, removing cookies you don't need,
    # rewriting the request, etc.
#}

sub vcl_backend_response {
    # Happens after we have read the response headers from the backend.
    #
    # Here you clean the response headers, removing silly Set-Cookie headers
    # and other mistakes your backend does.
}

sub vcl_deliver {
    # Happens when we have all the pieces we need, and are about to send the
    # response to the client.
    #
    # You can do accounting or modifying the final object here.
}

...