WP behind a Reverse Proxy – redirecting in loop
-
I am trying to forward/proxy all the traffic from only blog links from my old worpress website that is https://old_wordpress_host.com/blog to new host https://new_wordpress_host.com/
nginx block for proxy on old_wordpress_host.com.conf
location ^~ /blog { rewrite ^/blog(/.*)$ $1 break; proxy_ssl_server_name on; proxy_pass_request_headers on; proxy_pass https://new_wordpress_host.com/; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; server_name_in_redirect off;
}
And then in wordpress wp-config.php on new wordpress new_wordpress_host.com
define('.COOKIE_DOMAIN.', 'old_wordpress_host.com'); define('.SITECOOKIEPATH.', '.'); if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $list[0]; define('WP_SITEURL', 'https://old_wordpress_host.com/blog/'); define('WP_HOME', 'https://old_wordpress_host.com/blog/'); $_SERVER['HTTP_HOST'] = 'old_wordpress_host.com'; $_SERVER['REMOTE_ADDR'] = 'https://old_wordpress_host.com'; $_SERVER[ 'SERVER_ADDR' ] = 'old_wordpress_host.com'; if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){ $_SERVER['HTTPS']='on'; } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘WP behind a Reverse Proxy – redirecting in loop’ is closed to new replies.