D
D
DiGiTAll2016-06-18 13:50:47
URL Handling
DiGiTAll, 2016-06-18 13:50:47

How to configure CNC in WordPress on Nginx?

The Apache + Nginx bundle is installed on the server.
It is necessary that the CNC work in WordPress in this form:
site.ru/%category%/%postname%.html
This is already written in the settings of WP itself.
What should be written in the nginx config? Now it looks like this:

server {
    server_name mysite.ru www.mysite.ru;
    listen 178.100.100.97;
    charset UTF-8;
    disable_symlinks if_not_owner from=$root_path;
    set $root_path /var/www/mysite/data/www/mysite.ru;
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
      root $root_path;
      access_log /var/www/nginx-logs/mysite isp;
      access_log /var/www/httpd-logs/mysite.ru.access.log ;
      error_page 404 = @fallback;
    }
    location / {
      proxy_pass http://178.100.100.97:81;
      proxy_redirect http://178.100.100.97:81/ /;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
                       
    }

    location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
      proxy_pass http://178.100.100.97:81;
      proxy_redirect http://178.100.100.97:81/ /;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
    location @fallback {
      proxy_pass http://178.100.100.97:81;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
    location ^~ /webstat/ {
      auth_basic "Restricted area";
      auth_basic_user_file /var/www/mysite/data/etc/31337.passwd;
      try_files $uri @fallback;
    }
    include /usr/local/ispmgr/etc/nginx.inc;
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Belyaev, 2016-06-18
@cimmwolf

Paste in location / this setting:

try_files $uri $uri/ /index.php?$args;
location ~ [^/]\.ph(p\d*|tml)$ {
    try_files /does_not_exists @fallback;
}

You get this config:
server {
    server_name mysite.ru www.mysite.ru;
    listen 178.100.100.97;
    charset UTF-8;
    disable_symlinks if_not_owner from=$root_path;
    set $root_path /var/www/mysite/data/www/mysite.ru;
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
      root $root_path;
      access_log /var/www/nginx-logs/mysite isp;
      access_log /var/www/httpd-logs/mysite.ru.access.log ;
      error_page 404 = @fallback;
    }
    location / {
        try_files $uri $uri/ /index.php?$args;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @fallback;
        }              
    }

    location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
      proxy_pass http://178.100.100.97:81;
      proxy_redirect http://178.100.100.97:81/ /;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
    location @fallback {
      proxy_pass http://178.100.100.97:81;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
    location ^~ /webstat/ {
      auth_basic "Restricted area";
      auth_basic_user_file /var/www/mysite/data/etc/31337.passwd;
      try_files $uri @fallback;
    }
    include /usr/local/ispmgr/etc/nginx.inc;
  }

N
nikolayvaganov, 2016-06-18
@nikolayvaganov

insert :
в location /

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question