Hi, I'm working on a personal project, the subject is the following, the application itself is mounted in NodeJS
by topics that I need to use Socket.io
and the application connects with API
REST in PHP
CodeIgniter
for comfort issues regarding the code, it is hosted on the same server, the subject is as follows:
At the moment I was able to make the API
work since if I enter misitio.com/api/loquesea
it executes it well, the issue is that when entering the site in the root misitio.com/
the site that is made in NodeJS
with Angular
it does not show me anything, since the server tries to parse it as if it were CodeIgniter
returning a error 404
each time it loads a js
.
For example, this is the code I have at this time. All this is mounted in NGINX
:
server {
listen 80;
server_name misitio.com;
root /home/misitio.com/;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000;
proxy_redirect off;
}
if ($request_uri ~ ^api/index/?$){
rewrite ^/(.*)api/index/?$ /$1 permanent;
}
if (!-d $request_filename){
rewrite ^/(.+)/$ /$1 permanent;
}
if ($request_uri ~ ^api/system){
rewrite ^/(.*)$ /api/index.php?/$1 last;
break;
}
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/misitio.com/api$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht{
deny all;
}
}