'Ionic build in Docker container with nginx
I was playing around with Ionic the last couple of days and now i want to deploy my website in a Docker Container with nginx on it.
But there is a problem with the Routing: If i type in the IP-Adress of my server with the port (e.g.: http://10.0.0.1/) I will directly redirected to the Dashboard (http://10.0.0.1/dashboard).
As far so good: But if I press F5 in the Dashboard tab I get an 404 Not Found error.
I already read lots of Stackoverflow articles about this, the most of them say to change the nginx config. So here is my config:
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 {
listen 80;
listen 443 default_server ssl;
server_name localhost;
ssl_certificate /etc/nginx/fullchain.pem;
ssl_certificate_key /etc/nginx/privkey.pem;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
index index.html;
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
