当我try 通过Nginx反向代理访问我停靠的ANGLING应用程序时,页面没有完全加载,因为没有找到所有包含的脚本(404).
当我在位于Localhost:4200的expose 的坞站端口上直接访问它时,它加载正常.
基本URL设置为<base href="/">
例如,有一个脚本:
<link rel="stylesheet" href="styles-AVJWFAVY.css" media="print" onload="this.media='all'">
个
example.com/styles-AVJWFAVY.css -> 404
localhost:4200/styles-AVJWFAVY.css -> OK
Nginx(反向代理)
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name example.com;
# SSL
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
location / {
proxy_pass http://localhost:4200;
}
}
# HTTP redirect to HTTPS
server {
listen 80;
listen [::]:80;
server_name .example.com;
location / {
return 301 https://example.com$request_uri;
}
}
Dockerfile个
FROM node:latest as build
WORKDIR /usr/local/app
COPY ./ /usr/local/app/
RUN npm install
RUN npm run build
FROM nginx:latest
COPY --from=build /usr/local/app/dist/app/browser /usr/share/nginx/html
COPY /nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 4200
nginx.conf(在坞站环境中)
server {
listen 4200;
listen [::]:4200;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
我从sudo docker run -d --name personal-website -p 4200:4200 personal-website
开始停靠