首页 > 解决方案 > 您无权访问此资源 [在 apache 上部署 Angular 时]

问题描述

码头工人撰写

version: "2"

services: 
  django-apache2:
    build: .
    container_name: django-apache2
    ports:
      - '8005:80'
    volumes: 
      - ./www:/var/www/html/django_demo_app
      - ./angular/dist/ng7:/var/www/dist
      - ./demo_site.conf:/etc/apache2/sites-available/000-default.conf

泊坞窗文件

FROM python:3.7-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
    apt-utils \
    vim \
    curl \
    apache2 \
    apache2-utils

RUN apt-get -y install \
    libapache2-mod-wsgi-py3

ADD ./demo_site.conf /etc/apache2/sites-available/000-default.conf
COPY ./www /var/www/html
COPY ./angular/dist/ng7 /var/www/html/dist

EXPOSE 80
RUN rm /var/www/html/index.html
RUN chmod -R 777 /var/www/html/dist/index.html
CMD ["apache2ctl", "-D", "FOREGROUND"]

demo_site.conf

<VirtualHost *:80>
        ServerName localhost
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/dist

        Alias "/" "/var/www/html/dist"
        <Directory "/var/www/html/dist">
                Options FollowSymLinks Includes ExecCGI
                AllowOverride All
                Require all granted
        </Directory>    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我运行ng build并将包含 index.html 的构建工件放置在/var/www/html/dist.

我被禁止了 您无权访问此资源。在点击 localhost:8005 之后。

我在这里想念什么?

标签: angularjsapachedockerdocker-compose

解决方案


推荐阅读