Nginx locations configuration for two directions -



Nginx locations configuration for two directions -

i have little experience configuring nginx server , here trouble. trying set right locations. have 2 directs: address.com , address.com/api.

for lastly direction(api) have setted locations , works fine. api located in /var/www/project/api folder.

root /var/www/project; index index.php; server_name localhost; location /api { try_files /api/$uri $uri/ /api/index.php?$query_string; fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^/api/(.+\.php)(/.+)$; fastcgi_intercept_errors on; fastcgi_index index.php; include fastcgi_params; } location ~ \.php$ { try_files $uri =404; fastcgi_keep_conn on; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_buffer_size 32k; fastcgi_busy_buffers_size 64k; fastcgi_buffers 4 32k; fastcgi_split_path_info ^(.+\.php)(/.+)$; }

now need implement root address.com /var/www/project/website. , here have troubles.

first thing, did had written that:

location / { alias /var/www/project/website/; }

and tried add together many different variants , here lastly note.

i have set within location / {}

location ~ ^/(.+\.php)$ { alias /var/www/project/website/; include /etc/nginx/fastcgi.conf; proxy_intercept_errors on; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; }

in /etc/nginx/fastcgi.conf file have added

fastcgi_param path_translated $document_root$fastcgi_script_name;

and time 403 forbidden or 404 not found or in nginx errors log written that, example, /var/www/project/website/... not found.

has experience nginx configuring , can tell, how set /website location correct?

something that:

server { hear 80; server_name localhost; root /var/www/src/website; index index.php index.html; error_log /var/log/nginx/error.log; location / { try_files $uri $uri/ =404; } location /test { try_files $uri $uri/test.html =404; } location /api/ { alias /var/www/src/api/; try_files $uri $uri/ /index.php =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location /pmants { root /var/www/src/; index index.php index.html index.htm; location ~ ^/pmants/(.+\.php)$ { try_files $uri =404; root /var/www/src/; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ~* ^/pmants/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /var/www/src/; } } location ~* \.php { include fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param script_filename $document_root$fastcgi_script_name; fastcgi_cache off; fastcgi_index index.php; } }

nginx configuration location

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -