Answer the question
In order to leave comments, you need to log in
Two projects inside the same nginx domain?
There are two projects
1. Express
2. React
They must be on the same domain in the following ways.
`/` - express
`/admin/*` - react (all internal routes should always go through /var/www/front/user/dist/index.html.)
nginx:
server {
listen 80;
listen [::]:80;
server_name in.devo;
root /var/www/front/user/dist;
# react
location /admin {
alias /var/www/front/user/dist;
try_files $uri $uri/ /index.html;
location ~* /admin/.*\.(?:manifest|appcache|html?|xml|json)$ {
sendfile off;
expires off;
}
location ~* ^/admin/.*\.(?:css|js)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public";
}
location ~ ^/admin/.+\..+$ {
try_files $uri =404;
}
}
# express
location / {
add_header Access-Control-Allow-Origin *;
root /var/www/front/site;
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://127.0.0.1:3000/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Answer the question
In order to leave comments, you need to log in
What exactly is in /var/www/front/user/dist/route ?
1. If static, then it should be downloaded using nginx
2. If include files, then they must be moved to a higher level so that they are not available via http
3. If this request is processed by your application, which gives an error, then, accordingly, you need to fix this bug in the app
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question