W . A . X . O
ncc-1701
LINUX - UNIX




WORDPRESS AND A SERVER PROXY NGINX



1 - Prepare your proxy nginx vhost
  • Add this two lines in your vhost
            proxy_set_header    X-Forwarded-Proto   https;
            proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    	
  • Now, your web site section is like :
            location / {
            include proxy_params;
            proxy_pass http://your-really-web-server;
            proxy_set_header    X-Forwarded-Proto   https;
            proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
            }
    	
2 - Install Wordpress
  • Download Wordpress
    	sudo wget https://wordpress.org/latest.tar.gz
    	sudo tar -xzvf latest.tar.gz
    	
  • Rename the config file
    	sudo mv wp-config-sample.php wp-config.php
    	
3 - Configure your wp-config.php file
  • Add this lines to tell to wordpress to work with a proxy server nginx
  • Be carefull to add this lines before "That's all, stop editing! Happy publishing."
    	# Gracefully handle terminated SSL at reverse proxy
    	if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
        	$_SERVER['HTTPS'] = 'on';
    	}
    	
  • Set your database and user parameters in your config file
    	/** The name of the database for WordPress */
    	define( 'DB_NAME', 'MyDATABASE' );
    
    	/** Database username */
    	define( 'DB_USER', 'MyUSER' );
    
    	/** Database password */
    	define( 'DB_PASSWORD', 'xxxxxxxxxxxxxxxxx' );
    	
  • Please enjoy your new web site !
    	https://example.com/wp-admin/install.php