I have dockerized a yii2 app and local I can run the docker containers.
But I try now with a container registry and an web app to push the app on the azure cloud platform.
But on address: https://internetsuite2-0.azurewebsites.net/
I get every time the message:
Forbidden
You don't have permission to access this resource.
Apache/2.4.59 (Debian) Server at internetsuite2-0.azurewebsites.net Port 80
And I have tried a lot of thinks. I found an thread on this link:
https://learn.microsoft.com/en-us/answers/questions/208910/forbidden-you-dont-have-permission-to-access-this
I deleted the repository. And pushed again the whole folder to the repository. I restarted the app. But without results.
This is the dockerfile:
FROM yiisoftware/yii2-php:8.2-apache
RUN a2enmod rewrite
WORKDIR /internetsuite_2.0_backend
COPY . /internetsuite_2.0_backend
ADD composer.lock composer.json /internetsuite_2.0_backend/
RUN composer install --prefer-dist --optimize-autoloader --no-dev &&
composer clear-cache
RUN mkdir -p runtime web/assets &&
chmod -R 775 runtime web/assets &&
chown -R www-data:www-data runtime web/assets
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN service apache2 restart
docker-compose.yml:
version: "3.8"
services:
php:
image: crinternetsuite20backendtest.azurecr.io/web1
container_name: yii2
build:
context: ./
dockerfile: Dockerfile
restart: always
volumes:
- ~/.composer-docker/cache:/root/.composer/cache:delegated
- ./:/app:delegated
#command: php-fpm -R # Allow running FPM as root
ports:
- "8000:80"
env_file:
- ./.env
networks:
- yii
networks:
yii:
web.php in config:
<?php
// phpcs:ignoreFile
$params = require __DIR__ . '/params.php';
$db = require __DIR__ . '/db.php';
$config = [
'id' => 'basic',
'name' => 'internetsuite 2.0',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'modules' => [
'v1' => [
'class' => 'appmodulesv1Module',
],
],
'components' => [
'request' => [
'parsers' => [
'application/json' => 'yiiwebJsonParser',
],
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'OEtCunrAfQNETtmUSDnZw1JPHTB44i3A',
],
'cache' => [
'class' => 'yiicachingFileCache',
],
'user' => [
'identityClass' => 'appmodelsUser',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => yiisymfonymailerMailer::class,
'viewPath' => '@app/mail',
// send all mails to a file by default.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yiilogFileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
[
'class' => 'yiirestUrlRule',
'controller' => ['v1/user', 'v1/product'],
'pluralize' => false,
'extraPatterns' => [
'OPTIONS login' => 'options',
'OPTIONS signup' => 'options',
'OPTIONS user' => 'options',
'POST signup' => 'signup',
'POST login' => 'login',
'GET user' => 'user',
'GET index' => 'index'
],
],
],
],
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yiidebugModule',
// uncomment the following to add your IP if you are not connecting from localhost.
'allowedIPs' => ['127.0.0.1', 'https://internetsuite2-0.azurewebsites.net', '::1'],
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yiigiiModule',
// uncomment the following to add your IP if you are not connecting from localhost.
'allowedIPs' => ['127.0.0.1', 'https://internetsuite2-0.azurewebsites.net', '::1'],
];
}
return $config;
and index.php:
<?php
$path = dirname(__DIR__);
require $path . '/vendor/autoload.php';
$dotEnv = DotenvDotenv::createMutable($path);
$dotEnv->load();
defined('YII_DEBUG') or define('YII_DEBUG', $_ENV['YII_DEBUG']);
defined('YII_ENV') or define('YII_ENV', $_ENV['YII_ENV']);
require $path . '/vendor/yiisoft/yii2/Yii.php';
$config = require $path . '/config/web.php';
try {
(new yiiwebApplication($config))->run();
} catch (yiibaseInvalidConfigException $exception) {
echo $exception->getMessage();
}
I realy stuck on this issue.
Question: how to resolve the message: You don't have permission to access this resource.
on azure?