Answer the question
In order to leave comments, you need to log in
How to redirect routes in nginx?
How in nginx to redirect all routes at the beginning of which / api to the server so that they are processed there and the rest to angular?
Answer the question
In order to leave comments, you need to log in
> and the rest on angular?
I didn’t understand at all what angular has to do with it, but that’s not the point ...
Here is part of the real config:
server {
listen 80;
server_name example.com;
location /all.css {
root /srv/vek-node/static;
}
location /all.css.map {
root /srv/vek-node/static;
}
location /img {
root /srv/vek-node/static;
}
location /vendors {
root /srv/vek-node/static;
}
location /media {
alias /var/www/vek_staging/media;
}
location /catalog/metal {
rewrite ^ http://metal.example.com$request_uri? permanent;
}
location /admin {
uwsgi_read_timeout 600;
client_max_body_size 30m;
include /etc/nginx/uwsgi_params;
uwsgi_pass unix:/run/uwsgi/app/vek_staging/socket;
}
location /static {
alias /var/www/vek_staging/static;
}
location / {
include /etc/nginx/proxy_params;
proxy_read_timeout 120;
proxy_pass http://127.0.0.1:3331;
}
}
For example this is what I think:
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
location ~ api$ {
try_files $uri $uri/ /api.php?$args;
}
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-service.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $2;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question