I have a problem with NGinx configuration, I know that there are many topics, but I was not able to work normally ...
So, I have mydomain.com and mydomain.com/api/, my folders are similar to: /var/www/mydomain.com/website/dist and /var/www/mydomain.com/api/public
And at the moment, something almost works for me. But index.php still gets the / api part on my routes.
server {
listen 80;
server_name mydomain.com www.mydomain.com;
index index.php index.html;
location / {
root /var/www/mydomain.com/website/dist;
}
location ~ ^/api(/|$) {
root /var/www/mydomain.com/api/public;
try_files $uri /api/index.php;
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/tmp/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV production;
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'X-Requested-With,Content-Type,Authorization';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
}
access_log /var/logs/nginx/logs/mydomain.com-access.log;
error_log /var/logs/nginx/logs/mydomain.com-error.log;
}
I think I do not understand something with location or with php-fpm. What am I missing? What should I do to make this work properly?
I also read that the try_ file is enough for this than the rewrite rules ... I do not know: /
Thank you for your help!
source
share