Skip to content

Instantly share code, notes, and snippets.

@dilverdev
Last active May 11, 2021 07:07
Show Gist options
  • Save dilverdev/d2474459920b70a8988ea2d34099a175 to your computer and use it in GitHub Desktop.
Save dilverdev/d2474459920b70a8988ea2d34099a175 to your computer and use it in GitHub Desktop.
Create proxy reverse wordpress

Config ngnix principal

server {
    server_name www.domain.com domain.com;
    charset utf-8;

    location /blog/ {
        proxy_pass https://blog.domain.com;
        proxy_redirect                      off;
        proxy_set_header Host               $host;
    }

    location / {
        proxy_pass http://localhost:3000;
        proxy_redirect                      off;
        proxy_set_header Host               $host;
        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_read_timeout          1m;
        proxy_connect_timeout       1m;
    }
}

Config Wordpress

    server {
    	server_name blog.domain.com www.blog.domain.com;
    
    	root /var/www/blog;
    	index index.php index.html;
    
    	location / {
    		try_files $uri $uri/ /index.php?$args;
        }
    
        location ~ \.php$ {
    		include snippets/fastcgi-php.conf;
    		fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    	}
    }

wp-config.php

define('WP_HOME','https://domain.com/blog/');
define('WP_SITEURL',

define('WP_HOME','https://domain.com/blog/');
define('WP_SITEURL','https://domain.com/blog/');

$_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/",  $_SERVER['REQUEST_URI']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment