I've seen multiple answers to make nginx
server route an Angular application properly, but no solution has worked for me yet.
I ran nginx -s reload
after adding try_files
to etc/nginx/nginx.conf
The complete nginx.conf
file looks like this
user nginx;worker_processes 1;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events { worker_connections 1024;}http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request"''$status $body_bytes_sent "$http_referer"''"$http_user_agent""$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; server { location / { try_files $uri $uri/ /index.html; } }}
Also I've seen multiple answers making changes to /etc/nginx/sites-available/
but my nginx server simply does not have that folder.
Could it be the way I am deploying to my server? For that I am using docker as follows:
FROM node:alpine as BUILDWORKDIR /my-webCOPY package.json .RUN npm installCOPY . .RUN npm run buildFROM nginxEXPOSE 80COPY --from=BUILD /my-web/dist/app /usr/share/nginx/html
and the output path in angular.json
is "outputPath": "dist/app"
The url of the app is ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com
but refreshing pages and manually navigating to pages still does not work.
I am using Angular 8