Nginx / protect directory and Wordpress

Discussion in 'ISPConfig 3 Priority Support' started by cafeine65, Jun 3, 2013.

  1. cafeine65

    cafeine65 New Member

    Hi,

    I have some problems with nginx and wordpress and protect directory

    I have a wordpress site with permalink active :
    Code:
    www.mywebsite.com/index.php/%year%/%monthnum%/%day%/%postname%/
    I have a nginx and in ISP Config web site I add :
    Code:
    try_files $uri $uri/ /index.php?q=$uri&$args;
    It's work fine

    When I add a protect folder on / (base of my web site), I have a 404 not found

    here the code of the vhost
    Code:
    server {
            listen *:80;
    
    
            server_name mywebsite.com ;
    
            root   /var/www/mywebsite.com/web;
    
    
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    
    
    
            error_log /var/log/ispconfig/httpd/mywebsite.com/error.log;
            access_log /var/log/ispconfig/httpd/mywebsite.com/access.log combin$
    
            ## Disable .htaccess and other hidden files
            location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
            }
    
            location = /favicon.ico {
                log_not_found off;
                access_log off;
            }
    
            location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
            }
    
            location /stats {
    
                index index.html index.php;
                auth_basic "Members Only";
                auth_basic_user_file /var/www/clients/client1/web1/web/stats/.htpas$
            }
    
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files /4e59b599d97e7f99c0a520473a78ad7.htm @php;
            }
    
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9036;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9036;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                #fastcgi_param PATH_INFO $fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    
    
            try_files $uri $uri/ /index.php?q=$uri&$args;
    
            location / {
                    auth_basic "Members Only";
                    auth_basic_user_file /var/www/clients/client1/web1/web/.htpassw$
    
                    location ~ \.php$ {
                        try_files /4e59b599d97e7f99c0a520473a78ad7.htm @php;
                    }
            }
    
    }
    

    Have you a fix or an idea ?

    Thanks in advance
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Please try this configuration in the nginx Directives field instead:

    Code:
    location / {
                    try_files $uri $uri/ /index.php?$args;
    }
    
    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
    location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
    }
     
  3. cafeine65

    cafeine65 New Member

    thanks a lot. it's fine now. I put code on Directive Snippets for a future use.
     

Share This Page