We’ve just launched up another blog called SaaS Book (SaaSBook.net) which will be about the SaaS lessons we’ve learned through our SaaS product development journey.

The set up on that site was nginx as a reverse proxy to other services on that particular server.

The set up is nginx => Apache no special cases this time. See the nginx conf at the end of this post.

When we attempted to install WordPress and the installer couldn’t find jQuery, styles etc.

Everything was correctly set up and nginx was correctly installed and proxying requests to Apache.

I can’t believe WordPress still doesn’t detect this automatically or maybe via a constant.

The fix is to add this block of code in your wp-config.php file. It will override the HTTPS and HTTP_HOST values so apache is happy.

The apache server is running on port 8080 and doesn’t have https/ssl activated because it is handled at another level by nginx on port 80

	$_SERVER['HTTPS'] = 'on';
        $_SERVER['SERVER_PORT'] = 443;

if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {

The nginx virtual host set up is this.

# /etc/nginx/sites-enabled/20-example.com.conf
server {
    server_name saasbook.net www.saasbook.net;
    listen 80;
	# when the SSL is generated enable these lines and replace the example domain with yours
    #listen 443 ssl http2;
    #ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    #ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

	location / {
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $remote_addr;
		proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;