Nginx
2019.11.04 09:24
React router 404 에러 발생 시
다물칸 주소복사
조회 수 99 추천 수 0 댓글 0
구분 | 팁&트릭 |
---|---|
출처 | 내가작성 |
conf.d 에 vhost.conf 를 위 url에서 처럼 추가하자.
-
아래 server_name과 root의 경로만 설정하면 됨.
-
default.conf에서의 server_name은 아래와 다르게 localhost로 입력해야 한다.
server {
listen 80 default_server;
server_name {호스트아이피};
root /usr/share/nginx/html;
index index.html index.htm;
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}
location ~* \.(?:css|js)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
# Any route that doesn't have a file extension (e.g. /devices)
location / {
try_files $uri $uri/ /index.html;
}
}