Modify NGINX Config to work with Wordpress

SYSTEM INFORMATION
OS type and version Debian 11
Virtualmin version 7.7

Hi Community,

I finally have a new Virtualmin Server. This time with NGINX on it.
Since it’s my first time using NGINX, I want to ask you guys if you may can help out in modifying my NGINX config, maybe in a better way. Not sure, but until now everything is working.
What I did so far, was to put the rule inside this config, which Wordress generates in the .htaccess file on a Apache Server.

This is my config so far:

server {
	server_name xxxtest.dedyn.io www.xxxtest.dedyn.io mail.xxxtest.dedyn.io;
	listen 207.123.456.175;
	listen [2605:1234:5678:1341::100] default_server;
	root /home/xxxtest/public_html;
	index index.php index.htm index.html;
	access_log /var/log/virtualmin/xxxtest.dedyn.io_access_log;
	error_log /var/log/virtualmin/xxxtest.dedyn.io_error_log;
	fastcgi_param GATEWAY_INTERFACE CGI/1.1;
	fastcgi_param SERVER_SOFTWARE nginx;
	fastcgi_param QUERY_STRING $query_string;
	fastcgi_param REQUEST_METHOD $request_method;
	fastcgi_param CONTENT_TYPE $content_type;
	fastcgi_param CONTENT_LENGTH $content_length;
	fastcgi_param SCRIPT_FILENAME "/home/xxxtest/public_html$fastcgi_script_name";
	fastcgi_param SCRIPT_NAME $fastcgi_script_name;
	fastcgi_param REQUEST_URI $request_uri;
	fastcgi_param DOCUMENT_URI $document_uri;
	fastcgi_param DOCUMENT_ROOT /home/xxxtest/public_html;
	fastcgi_param SERVER_PROTOCOL $server_protocol;
	fastcgi_param REMOTE_ADDR $remote_addr;
	fastcgi_param REMOTE_PORT $remote_port;
	fastcgi_param SERVER_ADDR $server_addr;
	fastcgi_param SERVER_PORT $server_port;
	fastcgi_param SERVER_NAME $server_name;
	fastcgi_param PATH_INFO $fastcgi_path_info;
	fastcgi_param HTTPS $https;
	location ^~ /.well-known/ {
		try_files $uri /;
	}
	location / {
    		try_files $uri $uri/ /index.php?$args;
	}
	location ~ "\.php(/|$)" {
		try_files $uri $fastcgi_script_name =404;
		default_type application/x-httpd-php;
		fastcgi_pass unix:/var/php-fpm/16821413252991.sock;
	}
	fastcgi_split_path_info "^(.+\.php)(/.+)$";
	location /cgi-bin/ {
		gzip off;
		root /home/xxxtest/cgi-bin;
		fastcgi_pass unix:/var/fcgiwrap/16821413252991.sock/socket;
		fastcgi_param SCRIPT_FILENAME "/home/xxxtest$fastcgi_script_name";
		fastcgi_param GATEWAY_INTERFACE CGI/1.1;
		fastcgi_param SERVER_SOFTWARE nginx;
		fastcgi_param QUERY_STRING $query_string;
		fastcgi_param REQUEST_METHOD $request_method;
		fastcgi_param CONTENT_TYPE $content_type;
		fastcgi_param CONTENT_LENGTH $content_length;
		fastcgi_param SCRIPT_NAME $fastcgi_script_name;
		fastcgi_param REQUEST_URI $request_uri;
		fastcgi_param DOCUMENT_URI $document_uri;
		fastcgi_param DOCUMENT_ROOT /home/xxxtest/public_html;
		fastcgi_param SERVER_PROTOCOL $server_protocol;
		fastcgi_param REMOTE_ADDR $remote_addr;
		fastcgi_param REMOTE_PORT $remote_port;
		fastcgi_param SERVER_ADDR $server_addr;
		fastcgi_param SERVER_PORT $server_port;
		fastcgi_param SERVER_NAME $server_name;
		fastcgi_param PATH_INFO $fastcgi_path_info;
		fastcgi_param HTTPS $https;
	}
	listen 207.123.456.175:443 ssl;
	listen [2605:1234:5678:1341::100]:443 ssl default_server;
	ssl_certificate /etc/ssl/virtualmin/16821413252991/ssl.combined;
	ssl_certificate_key /etc/ssl/virtualmin/16821413252991/ssl.key;

I’m not sure at this point if there’s a way to make this configuration even better.

Thanks a lot upfront.

Even better for what? What are you trying to do?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.