nginx配置如下:
nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
sites-enabled > default
server {
listen 80 default_server;
listen [::]:80 default_server;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://127.0.0.1:3000;
}
location /admin/ {
root /root/cms-admin/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location ~ .*\.(js|css|png|jpg|gif|swf|ico|pdf|mov|mp3|wav|json|woff2)$ {
proxy_pass http://127.0.0.1:3000;
}
location /api/ {
proxy_pass http://127.0.0.1:3002/api/;
}
}
3000端口跑了一个ssr项目,可以正常访问
访问xxx/admin返回500,请问是哪里出了问题
可以确定/root/cms-admin/dist下存在index.html文件
粗看起来配得没问题呀。你确定xxx.com:3000/home这个页面存在吗?前端若是单页应用的话,就需要try_files到index.html