debian:jessie docker image does not install Nginx with HTTP/2 support

241 views Asked by At

I have this Dockerfile:

FROM debian:jessie

ARG ENV_APP
ARG ENV_SMF

RUN apt-get update && apt-get install -y nginx

ADD conf.d/nginx.conf /etc/nginx/
ADD conf.d/nginx.${ENV_SMF}.conf /etc/nginx/sites-available/symfony.conf

RUN ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/sites-enabled/symfony \
&& rm /etc/nginx/sites-enabled/default

RUN echo "upstream php-upstream { server grozissaviems_${ENV_APP}_php:9000; }" > /etc/nginx/conf.d/upstream.conf

RUN usermod -u 1000 www-data

EXPOSE 80
EXPOSE 443

By default this line apt-get install -y nginx installs nginx:

nginx version: nginx/1.6.2

Now, I need HTTP/2 enabled, but this nginx version is too old and does not support it. If I run typical check curl -I -L https://stg.grozissaviems.lt --insecure, the response is:

HTTP/1.1 200 OK
Server: nginx/1.21.1
Date: Wed, 06 Apr 2022 11:42:20 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/7.2.34
Cache-Control: max-age=0, must-revalidate, private
pragma: no-cache
Expires: Wed, 06 Apr 2022 11:42:20 GMT
Link: </build/images/landing_1350.webp>; rel="preload",</build/images/landing_800.webp>; rel="preload",</build/images/landing_1350.webp>; rel="preload",</build/images/landing_1350.png>; rel="preload",</build/images/landing_800.png>; rel="preload",</build/images/landing_1350.png>; rel="preload"
Strict-Transport-Security: max-age=31536000

Just to be sure I tried running same command from another image that has the newer nginx version 1.19.6 and the output is:

HTTP/2 200
server: nginx/1.21.1
date: Wed, 06 Apr 2022 11:42:31 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-powered-by: PHP/7.2.34
cache-control: max-age=0, must-revalidate, private
pragma: no-cache
expires: Wed, 06 Apr 2022 11:42:31 GMT
link: </build/images/landing_1350.webp>; rel="preload",</build/images/landing_800.webp>; rel="preload",</build/images/landing_1350.webp>; rel="preload",</build/images/landing_1350.png>; rel="preload",</build/images/landing_800.png>; rel="preload",</build/images/landing_1350.png>; rel="preload"
strict-transport-security: max-age=31536000

I assume the issue if of nginx being old. How can I fix it? I cannot find a way to upgrade (preferable install) newer nginx version when running docker.

P.S. apt-get update && apt-get-upgrade does not upgrade nginx version.

1

There are 1 answers

0
KelvinAhKe On

I had this problem lately and found out that the LTS for Debian 8 "Jessie" has ended on June 30, 2020, which is too old for me.

I changed to use the official Nginx Docker image.

Note that /etc/nginx/sites-enabled was no longer exist and default config was changed to /etc/nginx/conf.d/default.conf

In your case, it will become

FROM nginx:1.22

ARG ENV_APP
ARG ENV_SMF

ADD conf.d/nginx.conf /etc/nginx/
ADD conf.d/nginx.${ENV_SMF}.conf /etc/nginx/sites-available/symfony.conf

RUN ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/conf.d/symfony.conf \
&& rm /etc/nginx/conf.d/default.conf

RUN echo "upstream php-upstream { server grozissaviems_${ENV_APP}_php:9000; }" > /etc/nginx/conf.d/upstream.conf

RUN usermod -u 1000 www-data

EXPOSE 80
EXPOSE 443

CMD ["nginx"]