
아래와 같이 nginx.conf 파일로 찾으십시오.
server {
listen 81;
server_name www.mysite.com;
root /home/ubuntu/mysite/dist;
index index.php index.html index.htm;
charset utf-8;
# Remove trailing slash to please Laravel routing system.
#if (!-d $request_filename) {
#rewrite ^/(.+)/$ /$1 permanent;
#}
error_log /var/log/nginx/myapp-error.log warn;
location / {
try_files $uri /index.html;
}
location /temp {
alias /var/www/frontend-stage/dist/something/;
# basically $uri and /$uri resembles the base path which is / and the path on which we're currently, so for an example if i
# want to host another website on /temp/foo the the $uri /temp/$uri
try_files $uri $uri/ /temp/index.html;
}
...
크롬에서 www.mysite.com/temp/something을 열 때 index.html을 올바르게 가져오고 모든 js, css, jpeg, png 등은 /home/ubuntu/mysite/dist 대신 /var/www에서 가져옵니다. /프론트엔드 스테이지/dist/뭔가/
저는 프론트엔드에서 Angular 9를 사용하고 있습니다.
조언해주세요
답변1
문서 루트 세트가 있으므로 해당 경로 루트 /home/ubuntu/mysite/dist를 사용하고 있습니다.
여기를 보아라: https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/