简体   繁体   中英

How to set up SSL for container website in my condition (Apache2)

The architecture of my website

I just want to know how upto set up SSL to change the HTTP to HTTPS in my situation. I have tried to follow a few guidelines but still failed…

Is there any detailed instruction/steps to guide me to set up SSL in such env?

I run all my things in apache2.

already have a domain name.

Any help will be appreciated… Many thanks...

Short Answer

  • Create docker-compose.yml and Dockerfile files with required keywords and commands (port forwarding, naming, images, etc.)
  • Run a web server like Nginx or Apache
  • Configure your domain(s) conf file(s)
  • Install certbot in it for Let's Encrypt SSL for you domain
  • Open your required port numbers in firewall if needed (if you firewall configured, you may not need this step)
  • Run docker-compose up -d --build

Long Answer

docker-file.yml contents (read more in Compose Docs :

version: '3.9'

services:
    ANY_NAME:
        build: .
        restart: always
        ports:
            - 8201:8080
            - 8000:8101
    SECOND_NAME: # if you need more containers, copy this part
        build: .
        restart: always
        ports:
            - PORT_BE_ACCESSED_IN_WEB:LOCAL_PORT
volumes:
    SOME_NAME: {}

Docekrfile contents (read more in Dockerfile Docs ):

FROM nginx:latest # or any other base:version you need
# Your other commands goes there
# Example:
COPY ./domain.conf /etc/apache2/sites-available/
RUN a2ensite domain
RUN service apache2 reload
RUN apt-get update
RUN apt-get install certbot -y
RUN certbot ... # see certbot docs for more info
ENTRYPOINT ["some", "commands"]

Then run this command and if nothing goes wrong, it should be fine:

docker-compose up -d --build

Now it should be accessible via http://your_server_ip:8201 and http://your_server_ip:8000 . If it's fine, then check https://your_server_ip:8201 and https://your_server_ip:8000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM