Angular Nodejs+;Express | Wordpress | Nginx-静态文件服务问题
我正在尝试在AWS EC-2实例上使用Angular应用程序设置Wordpress博客 我面临的问题与静态文件有关,即css/js/images/等 角度应用程序位于Angular Nodejs+;Express | Wordpress | Nginx-静态文件服务问题,angular,wordpress,nginx,nginx-config,Angular,Wordpress,Nginx,Nginx Config,我正在尝试在AWS EC-2实例上使用Angular应用程序设置Wordpress博客 我面临的问题与静态文件有关,即css/js/images/等 角度应用程序位于/home/ubuntu/project/ Wordpress位于/var/www/html/blog/ 我想设置www.example.com角度应用程序及其所有路线。 对于wordpress,www.example.com/blog及其所有路线 目前,wordpress与我当前的nginx配置配合得很好 当前Nginx配置: s
/home/ubuntu/project/
Wordpress位于
/var/www/html/blog/
我想设置www.example.com角度应用程序及其所有路线。
对于wordpress,www.example.com/blog及其所有路线
目前,wordpress与我当前的nginx配置配合得很好
当前Nginx配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /mnt/d/VCN/nginx/html;
access_log /var/www/html/website/access.log;
error_log /var/www/html/website/error.log;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location / {
proxy_pass http://127.0.0.1:4000/;
}
location /blog {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffering off;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
}
问题:
我现在不能为角度应用提供静态图像。如果我更改服务器块中的根目录
,Wordpress将停止工作。如果我在/location中添加root
,Angular应用程序仍然无法获取图像并返回404。
我甚至尝试为/blog
位置设置一个单独的root
字段,但它仍然不起作用
我甚至尝试使用/assets/images
东西,使所有静态文件都可以从assets
文件夹中获得服务,但仍然不起作用
如果有人能破解它,也请解释一下解决方案。这将更容易发现逻辑上的缺陷以及事情不顺利的原因
我使用Angular cli,因此文件夹结构相同
我也尝试了一个简单的nodejs/expressjs应用程序,但它不起作用。简单Nodejs/Expressjs应用程序的文件夹结构为
/home/ubuntu/test/
|-node_modules
|-public
|-css
|-js
|-index.html
|-server.js