Для контекста: у меня есть удаленный компьютер с Apache, настроенный на перенаправление трафика к приложениям, развернутым на подмаршрутах купленного домена. Например, это мой файл конфигурации Apache:
Код: Выделить всё
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
#ServerName [name of the server, omited for reasons]
ProxyPreserveHost On
ProxyPass /app1 http://127.0.0.1:2322
ProxyPassReverse /app1 http://127.0.0.1:2322
ProxyPass /app2 http://127.0.0.1:3000
ProxyPassReverse /app2 http://127.0.0.1:3000
ProxyPass /app3 http://127.0.0.1:3002
ProxyPassReverse /app3 http://127.0.0.1:3002
ProxyPass /app4 http://127.0.0.1:3001/app4
ProxyPassReverse /app5 http://127.0.0.1:3001/app4
# New app configuration for /new-app
ProxyPass /new-app http://127.0.0.1:3000/new-app
ProxyPassReverse /new-app http://127.0.0.1:3000/new-app
ServerName www.example.com [replaced the domain for example.com]
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias example.com
SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
Код: Выделить всё
# Stage 1: Base
FROM oven/bun:latest AS base
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install
COPY . .
# Stage 2: Production build
FROM base AS build
RUN bun run build
# Stage 3: Production environment
FROM nginx:alpine AS production
# Copy the built files from the previous stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copia la configuración de nginx personalizada
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Start Nginx server
CMD ["nginx", "-g", "daemon off;"]
Код: Выделить всё
server {
listen 80;
server_name localhost;
# routing with /new-app/ prefix
location /new-app/ {
alias /usr/share/nginx/html/;
index index.html;
try_files $uri $uri/ index.html;
}
# Handle other routes
location / {
try_files $uri $uri/ /index.html;
}
}
Кстати, внутри контейнера статические файлы правильно копируются внутри:
Код: Выделить всё
/ # ls /usr/share/nginx/html/
50x.html assets fondo.webp index.html logos
Любая помощь приветствуется. Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/792 ... to-an-ngin