Last active
April 12, 2023 19:42
-
-
Save varaskkar/a0dd7a1b7283d10cc976684f96fe7584 to your computer and use it in GitHub Desktop.
Docker Compose: Nginx + PHP + SSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
index index.php index.html; | |
server_name phpfpm.local; | |
error_log /var/log/nginx/error.log; | |
access_log /var/log/nginx/access.log; | |
root /var/www/html; | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass php-fpm:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.3" | |
services: | |
web: | |
image: nginx:1.23.3-alpine | |
expose: | |
- "80" | |
volumes: | |
- ./src:/var/www/html | |
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf | |
environment: | |
- VIRTUAL_HOST=alarmsworld.com,www.alarmsworld.com | |
- LETSENCRYPT_HOST=alarmsworld.com,www.alarmsworld.com | |
- [email protected] | |
depends_on: | |
- php-fpm | |
- nginx-proxy | |
- letsencrypt | |
php-fpm: | |
image: php:8-fpm | |
volumes: | |
- ./src:/var/www/html | |
nginx-proxy: | |
image: jwilder/nginx-proxy | |
restart: always | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- /var/run/docker.sock:/tmp/docker.sock:ro | |
- certs:/etc/nginx/certs:ro | |
- vhostd:/etc/nginx/vhost.d | |
- html:/usr/share/nginx/html | |
labels: | |
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy | |
letsencrypt: | |
image: jrcs/letsencrypt-nginx-proxy-companion | |
restart: always | |
environment: | |
- NGINX_PROXY_CONTAINER=nginx-proxy | |
volumes: | |
- certs:/etc/nginx/certs:rw | |
- html:/usr/share/nginx/html | |
- vhostd:/etc/nginx/vhost.d | |
- /var/run/docker.sock:/var/run/docker.sock:ro | |
volumes: | |
certs: | |
html: | |
vhostd: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Build this structure:
Steps:
docker-compose.yml
changealarmsworld.com
to your domain name (from GoDaddy, Google Domains, ...)docker-compose up -d
in /myfolder path