B
B
Bygaga2015-03-15 13:03:38
Nginx
Bygaga, 2015-03-15 13:03:38

How to display /admin/ as /index.php/admin/ with existing /admin/ directory using Nginx?

There is a directory /admin/[css/image/js for admin]
The path example.com/admin (/) should show the control panel, but:
example.com/admin - 403 Forbidden
example.com/admin - redirect to example.com :8092/admin - and response 403 Forbidden
Config

upstream examplebackend {
    server 127.0.0.1:8092;
}

server {
      server_name example.com;
  
      charset utf-8;
      default_type text/html;
    	root /var/www/example;
    	ssi on;
    	index index.php;

    	# to get real user ip
      proxy_set_header Host $host;
      proxy_set_header        X-Real-IP       $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  
      location / {
            proxy_pass http://examplebackend;
    	}

    	location ~* ^.+\.(ico|jpe?g|gif|png|svg|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|xls|pdf|doc|txt|flv|js|css)$ {
            ssi off;
            expires 1d;
    		    error_page 404 = @process;
    	}

    	location @process {
            proxy_pass http://examplebackend;
    	}
}

server {
    listen 8092;

    charset utf-8;
    default_type text/html;
    root /var/www/example;
    
    index index.php;
    client_max_body_size 80m;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param APP_CONFIG development;
        fastcgi_param REMOTE_ADDR $http_x_real_ip;
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question