WordPress with nginx

See https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/


    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
        # This is cool because no php is touched for static content.
        # include the "?$args" part so non-default permalinks doesn't break when using query string
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/var/php-nginx/162475923957101.sock/socket;
        #The following parameter can be also included in fastcgi_params file
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }

Setup Virtualmin with nginx and a custom domain

  1. In webmin, create a virtual server for your panel, eg webmin.example.com and usermin.example.com
  2. Go to Webmin > Webmin Configuration > Ports and Addresses, set Web server hostname to webmin.example.com
  3. Go to Webmin > Usermin Configuration > Ports and Addresses, set Web server hostname to usermin.example.com.
    3.2. In case you want usermin hosted on a same domain but a different path to webmin (eg webmin.example.com for webmin and webmin.example.com/ucp/ for usermin) just enter webmin.example.com
  4. Edit nginx server configuration file for domain webmin.example.com
upstream webmin-upstream {
	server localhost:10000;
}
upstream usermin-upstream {
	server localhost:20000;
}
server {
...
    location /ucp/ {

		# set some headers and proxy stuff.
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		#proxy_redirect off;

		# include Host header
		proxy_set_header Host $http_host;

		# proxy request to usermin server
		proxy_pass https://usermin-upstream/;
		
		# Fixes initial redirect after login
		proxy_redirect https://$host:20000/ https://$http_host/;
	}
	location / {

		# set some headers and proxy stuff.
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		#proxy_redirect off;

		# include Host header
		proxy_set_header Host $http_host;

		# proxy request to webmin server
		proxy_pass https://webmin-upstream/;
		
		# Fixes initial redirect after login
		proxy_redirect https://$host:10000/ https://$http_host/;
	}

Setup ghost blog with nginx

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://192.168.1.35:3001/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 900;
        proxy_redirect off;
    }