我正在尝试使用ninx反向代理功能在AWS上部署nuxt.js(SSR模式)。
我如下配置/etc/nginx/sites-available/hoge.com
文件,
与官方常见问题解答相同:https://nuxtjs.org/faq/nginx-proxy/
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
listen 80;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location / {
expires $expires;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://127.0.0.1:3000;
}
}
如果我访问http://hoge.com,则可以使用。
但是在下面更改位置路径后,nuxt.js无法呈现自身。
重写hoge.com
文件时...
server {
...
- location / {
+ location /fuga/ {
...
}
}
然后访问http://hoge.com/fuga/,它不起作用
console.log
GET http://hoge.com/_nuxt/a7cb158397e68912ff29.js net::ERR_ABORTED 404 (Not Found)
(index):569 GET http://hoge.com/_nuxt/img/7f93e7b.png 404 (Not Found)
(index):567 GET http://hoge.com/_nuxt/img/37def1e.png 404 (Not Found)
6(index):569 GET http://hoge.com/_nuxt/img/d9ced4d.png 404 (Not Found)
(index):1 Unchecked runtime.lastError: The message port closed before a response was received.
favicon.ico:1 GET http://hoge.com/favicon.ico 404 (Not Found)
似乎资源文件路径仍引用先前的URL。
但是我不知道如何解决它。