Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the 'secure' and the 'httpOnly' attribute for any session cookie from DOCKERFILE #12

Open
Ibra95ak-pomechain opened this issue May 22, 2021 · 0 comments

Comments

@Ibra95ak-pomechain
Copy link

I'm using this dockerfile image for my project and I want to set the 'secure' and the 'httpOnly' attribute to true.

My main goal is to have them as default values for all cookies and sessions on the server.

I added the ENV variables corresponding to that :

ENV PHP_SESSION_COOKIE_SECURE=On
ENV PHP_SESSION_COOKIE_PATH=/
ENV PHP_SESSION_COOKIE_HTTPONLY=On

Also, I tried :


ENV PHP_SESSION_COOKIE_SECURE=true
ENV PHP_SESSION_COOKIE_PATH=/
ENV PHP_SESSION_COOKIE_HTTPONLY=true

And still, I see them set as false when I browse the website.
cookies

Here is my dockerfile:


FROM alpine:edge
MAINTAINER Paul Smith <pa.ulsmith.net>

# Add repos
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories

# Add basics first
RUN apk update && apk upgrade && apk add \
    bash apache2 php7-apache2 curl ca-certificates openssl openssh git php7 php7-phar php7-json php7-iconv php7-openssl tzdata openntpd nano

# Add Composer
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer

# Setup apache and php
RUN apk add \
    php7-ftp \
    php7-xdebug \
    php7-mcrypt \
    php7-mbstring \
    php7-soap \
    php7-gmp \
    php7-pdo_odbc \
    php7-dom \
    php7-pdo \
    php7-zip \
    php7-mysqli \
    php7-sqlite3 \
    php7-pdo_pgsql \
    php7-bcmath \
    php7-gd \
    php7-odbc \
    php7-pdo_mysql \
    php7-pdo_sqlite \
    php7-gettext \
    php7-xml \
    php7-xmlreader \
    php7-xmlwriter \
    php7-tokenizer \
    php7-xmlrpc \
    php7-bz2 \
    php7-pdo_dblib \
    php7-curl \
    php7-ctype \
    php7-session \
    php7-redis \
    php7-exif \
    php7-intl \
    php7-fileinfo \
    php7-ldap \
    php7-apcu

# Problems installing in above stack
RUN apk add php7-simplexml

RUN cp /usr/bin/php7 /usr/bin/php \
    && rm -f /var/cache/apk/*

# Add apache to run and configure
RUN sed -i "s/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/" /etc/apache2/httpd.conf \
    && sed -i "s/#LoadModule\ session_module/LoadModule\ session_module/" /etc/apache2/httpd.conf \
    && sed -i "s/#LoadModule\ session_cookie_module/LoadModule\ session_cookie_module/" /etc/apache2/httpd.conf \
    && sed -i "s/#LoadModule\ session_crypto_module/LoadModule\ session_crypto_module/" /etc/apache2/httpd.conf \
    && sed -i "s/#LoadModule\ deflate_module/LoadModule\ deflate_module/" /etc/apache2/httpd.conf \
    && sed -i "s#^DocumentRoot \".*#DocumentRoot \"/app/public\"#g" /etc/apache2/httpd.conf \
    && sed -i "s#/var/www/localhost/htdocs#/app/public#" /etc/apache2/httpd.conf \
    && printf "\n<Directory \"/app/public\">\n\tAllowOverride All\n</Directory>\n" >> /etc/apache2/httpd.conf
ENV PHP_ALLOW_URL_INCLUDE=On
ENV PHP_SESSION_COOKIE_SECURE=true
ENV PHP_SESSION_COOKIE_PATH=/
ENV PHP_SESSION_COOKIE_HTTPONLY=true
RUN mkdir /app && mkdir /app/public && chown -R apache:apache /app && chmod -R 755 /app && mkdir bootstrap
COPY app/ /app/public/
USER root
RUN chmod 0777 /app/public/api/emiratespost/awbpdf/
RUN chmod 0777 /app/public/assets/media/companies/
RUN chmod 0777 /app/public/assets/media/licenses/
RUN chmod 0777 /app/public/assets/media/payments/
RUN chmod 0777 /app/public/assets/media/products/
RUN chmod 0777 /app/public/assets/media/shipments/
ADD start.sh /bootstrap/
RUN chmod +x /bootstrap/start.sh

EXPOSE 80
ENTRYPOINT ["/bootstrap/start.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant