Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to wordpress vhost for nginx #26

Open
valentinomariotto opened this issue Oct 17, 2022 · 0 comments
Open

improvements to wordpress vhost for nginx #26

valentinomariotto opened this issue Oct 17, 2022 · 0 comments

Comments

@valentinomariotto
Copy link

Hi Juan,
I found that the bundled Wordpress configuration for Nginx doesn't work well.
Please consider providing the following configuration instead. I'm no expert, but this works:

# /etc/nginx/sites-available/wordpress.conf
# Wordpress

map $cookie_XDEBUG_SESSION $my_fastcgi_pass {
    default 127.0.0.1:9000;
    xdebug  127.0.0.1:${phpfpm_xdebug_port};
}

server {
    listen *:${nginxport} default_server;

    server_name _;
    root /var/www;
    index index.php;
	

    location / {
		try_files $uri $uri/ /index.php?$args;
    }
	
	rewrite /wp-admin$ $scheme://$host$uri/ permanent;
	
	# WPLM fix
	rewrite ^/en/wp-login.php /wp-login.php break;
	rewrite ^/de/wp-login.php /wp-login.php break;
	rewrite ^/fr/wp-login.php /wp-login.php break;
	rewrite ^/es/wp-login.php /wp-login.php break;
	rewrite ^/it/wp-login.php /wp-login.php break;

    location ~ \.php(/|$) {
        set $path_info $fastcgi_path_info;

        fastcgi_pass $my_fastcgi_pass;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }

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

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

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

    location ~ /\. {
        deny all;
    }
	
	location ~ /\.svn/* {
        deny all;
    }

    location ~ /\.git/* {
        deny all;
    }
	
	location /nginx_status {
        stub_status on;
        access_log off;
    }
	
	location ~ ^/(status|ping)$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
        allow 127.0.0.1;
        deny all;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant