Open yativilli opened 2 months ago
Use Nginx as a reverse Proxy Server - Makes it easier to navigate and bundles it to one URL: Setup with Node and here with Docker and Nodejs
Code for Nginx-Config could look something like this: `server { listen 80; server_name your_domain_or_ip;
# Serve Angular app (assuming built Angular files are in /var/www/angular-app/dist/)
location / {
root /var/www/angular-app/dist;
try_files $uri $uri/ /index.html;
}
# Reverse proxy for API requests to Express.js
location /api/ {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# Additional headers for security
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
# Error page handling
error_page 404 /index.html;
location = /index.html {
internal;
}
}`
When using Dockercompose-Volumes in Docker, there are two different ways to react to them; Either mount them or save them in docker: Saving in Docker Saving in docker is done through giving the file a specified name like my_db;/var/lib/mysql. It is then stored in docker internally. Meaning it is persistend through deletions of containers. Mounting Mounting is done to reflect changes from the local repository to the docker container: ./express:/app -> The Source code and files from the local repository is mounted from the local subfolder "express" to the folder "app" in docker. This is used for source code and configurations.