[{"data":1,"prerenderedAt":776},["Reactive",2],{"content-query-QkkZzkhV13":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"head":10,"layout":12,"body":13,"_type":771,"_id":772,"_source":773,"_file":774,"_extension":775},"/docs/customizing-the-image/configuring-ssl","customizing-the-image",false,"","Configuring SSL","Learn how to use SSL with the serversideup/php images.",{"title":11},"Configuring SSL - Docker PHP - Server Side Up","docs",{"type":14,"children":15,"toc":764},"root",[16,24,39,77,84,111,292,297,303,308,502,519,548,553,628,657,670,689,696,726,732,753,758],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"configuring-ssl",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28,30,37],{"type":23,"value":29},"SSL is disabled by default but can be turned on by setting ",{"type":17,"tag":31,"props":32,"children":34},"code",{"className":33},[],[35],{"type":23,"value":36},"SSL_MODE",{"type":23,"value":38},":",{"type":17,"tag":40,"props":41,"children":42},"ul",{},[43,55,66],{"type":17,"tag":44,"props":45,"children":46},"li",{},[47,53],{"type":17,"tag":31,"props":48,"children":50},{"className":49},[],[51],{"type":23,"value":52},"off",{"type":23,"value":54}," (default): HTTP only.",{"type":17,"tag":44,"props":56,"children":57},{},[58,64],{"type":17,"tag":31,"props":59,"children":61},{"className":60},[],[62],{"type":23,"value":63},"mixed",{"type":23,"value":65},": HTTP and HTTPS.",{"type":17,"tag":44,"props":67,"children":68},{},[69,75],{"type":17,"tag":31,"props":70,"children":72},{"className":71},[],[73],{"type":23,"value":74},"on",{"type":23,"value":76},": HTTPS only. HTTP requests will be redirected to HTTPS.",{"type":17,"tag":78,"props":79,"children":81},"h2",{"id":80},"self-signed-certificate-example",[82],{"type":23,"value":83},"Self-signed Certificate Example",{"type":17,"tag":25,"props":85,"children":86},{},[87,89,94,96,101,103,109],{"type":23,"value":88},"If you set ",{"type":17,"tag":31,"props":90,"children":92},{"className":91},[],[93],{"type":23,"value":36},{"type":23,"value":95}," to ",{"type":17,"tag":31,"props":97,"children":99},{"className":98},[],[100],{"type":23,"value":63},{"type":23,"value":102}," or ",{"type":17,"tag":31,"props":104,"children":106},{"className":105},[],[107],{"type":23,"value":108},"full",{"type":23,"value":110},", a self-signed certificate will be generated by default.",{"type":17,"tag":112,"props":113,"children":115},"code-panel",{"label":114},"Set SSL mode to \"mixed\" (HTTP + HTTPS)",[116],{"type":17,"tag":117,"props":118,"children":122},"pre",{"className":119,"code":120,"language":121,"meta":7,"style":7},"language-yaml shiki shiki-themes github-dark github-dark monokai","version: '3'\nservices:\n  php:\n    image: serversideup/php:8.3-fpm-nginx\n    ports:\n      - 80:8080\n      - 443:8443\n    environment:\n      SSL_MODE: \"mixed\"\n    volumes:\n      - .:/var/www/html\n","yaml",[123],{"type":17,"tag":31,"props":124,"children":125},{"__ignoreMap":7},[126,150,164,177,195,208,222,235,248,266,279],{"type":17,"tag":127,"props":128,"children":131},"span",{"class":129,"line":130},"line",1,[132,138,144],{"type":17,"tag":127,"props":133,"children":135},{"style":134},"--shiki-default:#85E89D;--shiki-dark:#85E89D;--shiki-sepia:#F92672",[136],{"type":23,"value":137},"version",{"type":17,"tag":127,"props":139,"children":141},{"style":140},"--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8;--shiki-sepia:#F8F8F2",[142],{"type":23,"value":143},": ",{"type":17,"tag":127,"props":145,"children":147},{"style":146},"--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF;--shiki-sepia:#E6DB74",[148],{"type":23,"value":149},"'3'\n",{"type":17,"tag":127,"props":151,"children":153},{"class":129,"line":152},2,[154,159],{"type":17,"tag":127,"props":155,"children":156},{"style":134},[157],{"type":23,"value":158},"services",{"type":17,"tag":127,"props":160,"children":161},{"style":140},[162],{"type":23,"value":163},":\n",{"type":17,"tag":127,"props":165,"children":167},{"class":129,"line":166},3,[168,173],{"type":17,"tag":127,"props":169,"children":170},{"style":134},[171],{"type":23,"value":172},"  php",{"type":17,"tag":127,"props":174,"children":175},{"style":140},[176],{"type":23,"value":163},{"type":17,"tag":127,"props":178,"children":180},{"class":129,"line":179},4,[181,186,190],{"type":17,"tag":127,"props":182,"children":183},{"style":134},[184],{"type":23,"value":185},"    image",{"type":17,"tag":127,"props":187,"children":188},{"style":140},[189],{"type":23,"value":143},{"type":17,"tag":127,"props":191,"children":192},{"style":146},[193],{"type":23,"value":194},"serversideup/php:8.3-fpm-nginx\n",{"type":17,"tag":127,"props":196,"children":198},{"class":129,"line":197},5,[199,204],{"type":17,"tag":127,"props":200,"children":201},{"style":134},[202],{"type":23,"value":203},"    ports",{"type":17,"tag":127,"props":205,"children":206},{"style":140},[207],{"type":23,"value":163},{"type":17,"tag":127,"props":209,"children":211},{"class":129,"line":210},6,[212,217],{"type":17,"tag":127,"props":213,"children":214},{"style":140},[215],{"type":23,"value":216},"      - ",{"type":17,"tag":127,"props":218,"children":219},{"style":146},[220],{"type":23,"value":221},"80:8080\n",{"type":17,"tag":127,"props":223,"children":225},{"class":129,"line":224},7,[226,230],{"type":17,"tag":127,"props":227,"children":228},{"style":140},[229],{"type":23,"value":216},{"type":17,"tag":127,"props":231,"children":232},{"style":146},[233],{"type":23,"value":234},"443:8443\n",{"type":17,"tag":127,"props":236,"children":238},{"class":129,"line":237},8,[239,244],{"type":17,"tag":127,"props":240,"children":241},{"style":134},[242],{"type":23,"value":243},"    environment",{"type":17,"tag":127,"props":245,"children":246},{"style":140},[247],{"type":23,"value":163},{"type":17,"tag":127,"props":249,"children":251},{"class":129,"line":250},9,[252,257,261],{"type":17,"tag":127,"props":253,"children":254},{"style":134},[255],{"type":23,"value":256},"      SSL_MODE",{"type":17,"tag":127,"props":258,"children":259},{"style":140},[260],{"type":23,"value":143},{"type":17,"tag":127,"props":262,"children":263},{"style":146},[264],{"type":23,"value":265},"\"mixed\"\n",{"type":17,"tag":127,"props":267,"children":269},{"class":129,"line":268},10,[270,275],{"type":17,"tag":127,"props":271,"children":272},{"style":134},[273],{"type":23,"value":274},"    volumes",{"type":17,"tag":127,"props":276,"children":277},{"style":140},[278],{"type":23,"value":163},{"type":17,"tag":127,"props":280,"children":282},{"class":129,"line":281},11,[283,287],{"type":17,"tag":127,"props":284,"children":285},{"style":140},[286],{"type":23,"value":216},{"type":17,"tag":127,"props":288,"children":289},{"style":146},[290],{"type":23,"value":291},".:/var/www/html\n",{"type":17,"tag":25,"props":293,"children":294},{},[295],{"type":23,"value":296},"The above will generate a self-signed certificate and configure NGINX to listen on both HTTP (Port 80) and HTTPS (Port 443).",{"type":17,"tag":78,"props":298,"children":300},{"id":299},"providing-your-own-certificate",[301],{"type":23,"value":302},"Providing Your Own Certificate",{"type":17,"tag":25,"props":304,"children":305},{},[306],{"type":23,"value":307},"In order to add your own certificate, you will need to mount the certificate files to the container. The following files are required:",{"type":17,"tag":112,"props":309,"children":311},{"label":310},"Providing your own certificate pair",[312],{"type":17,"tag":117,"props":313,"children":315},{"className":119,"code":314,"language":121,"meta":7,"style":7},"version: '3'\nservices:\n  php:\n    image: serversideup/php:8.3-fpm-nginx\n    ports:\n      - 80:8080\n      - 443:8443\n    environment:\n      SSL_MODE: \"mixed\"\n      SSL_PRIVATE_KEY_FILE: \"/etc/ssl/private/test-key.pem\"\n      SSL_CERTIFICATE_FILE: \"/etc/ssl/private/test.pem\"\n    volumes:\n      - ./app:/var/www/html\n      - ./certs/:/etc/ssl/private/\n",[316],{"type":17,"tag":31,"props":317,"children":318},{"__ignoreMap":7},[319,334,345,356,371,382,393,404,415,430,447,464,476,489],{"type":17,"tag":127,"props":320,"children":321},{"class":129,"line":130},[322,326,330],{"type":17,"tag":127,"props":323,"children":324},{"style":134},[325],{"type":23,"value":137},{"type":17,"tag":127,"props":327,"children":328},{"style":140},[329],{"type":23,"value":143},{"type":17,"tag":127,"props":331,"children":332},{"style":146},[333],{"type":23,"value":149},{"type":17,"tag":127,"props":335,"children":336},{"class":129,"line":152},[337,341],{"type":17,"tag":127,"props":338,"children":339},{"style":134},[340],{"type":23,"value":158},{"type":17,"tag":127,"props":342,"children":343},{"style":140},[344],{"type":23,"value":163},{"type":17,"tag":127,"props":346,"children":347},{"class":129,"line":166},[348,352],{"type":17,"tag":127,"props":349,"children":350},{"style":134},[351],{"type":23,"value":172},{"type":17,"tag":127,"props":353,"children":354},{"style":140},[355],{"type":23,"value":163},{"type":17,"tag":127,"props":357,"children":358},{"class":129,"line":179},[359,363,367],{"type":17,"tag":127,"props":360,"children":361},{"style":134},[362],{"type":23,"value":185},{"type":17,"tag":127,"props":364,"children":365},{"style":140},[366],{"type":23,"value":143},{"type":17,"tag":127,"props":368,"children":369},{"style":146},[370],{"type":23,"value":194},{"type":17,"tag":127,"props":372,"children":373},{"class":129,"line":197},[374,378],{"type":17,"tag":127,"props":375,"children":376},{"style":134},[377],{"type":23,"value":203},{"type":17,"tag":127,"props":379,"children":380},{"style":140},[381],{"type":23,"value":163},{"type":17,"tag":127,"props":383,"children":384},{"class":129,"line":210},[385,389],{"type":17,"tag":127,"props":386,"children":387},{"style":140},[388],{"type":23,"value":216},{"type":17,"tag":127,"props":390,"children":391},{"style":146},[392],{"type":23,"value":221},{"type":17,"tag":127,"props":394,"children":395},{"class":129,"line":224},[396,400],{"type":17,"tag":127,"props":397,"children":398},{"style":140},[399],{"type":23,"value":216},{"type":17,"tag":127,"props":401,"children":402},{"style":146},[403],{"type":23,"value":234},{"type":17,"tag":127,"props":405,"children":406},{"class":129,"line":237},[407,411],{"type":17,"tag":127,"props":408,"children":409},{"style":134},[410],{"type":23,"value":243},{"type":17,"tag":127,"props":412,"children":413},{"style":140},[414],{"type":23,"value":163},{"type":17,"tag":127,"props":416,"children":417},{"class":129,"line":250},[418,422,426],{"type":17,"tag":127,"props":419,"children":420},{"style":134},[421],{"type":23,"value":256},{"type":17,"tag":127,"props":423,"children":424},{"style":140},[425],{"type":23,"value":143},{"type":17,"tag":127,"props":427,"children":428},{"style":146},[429],{"type":23,"value":265},{"type":17,"tag":127,"props":431,"children":432},{"class":129,"line":268},[433,438,442],{"type":17,"tag":127,"props":434,"children":435},{"style":134},[436],{"type":23,"value":437},"      SSL_PRIVATE_KEY_FILE",{"type":17,"tag":127,"props":439,"children":440},{"style":140},[441],{"type":23,"value":143},{"type":17,"tag":127,"props":443,"children":444},{"style":146},[445],{"type":23,"value":446},"\"/etc/ssl/private/test-key.pem\"\n",{"type":17,"tag":127,"props":448,"children":449},{"class":129,"line":281},[450,455,459],{"type":17,"tag":127,"props":451,"children":452},{"style":134},[453],{"type":23,"value":454},"      SSL_CERTIFICATE_FILE",{"type":17,"tag":127,"props":456,"children":457},{"style":140},[458],{"type":23,"value":143},{"type":17,"tag":127,"props":460,"children":461},{"style":146},[462],{"type":23,"value":463},"\"/etc/ssl/private/test.pem\"\n",{"type":17,"tag":127,"props":465,"children":467},{"class":129,"line":466},12,[468,472],{"type":17,"tag":127,"props":469,"children":470},{"style":134},[471],{"type":23,"value":274},{"type":17,"tag":127,"props":473,"children":474},{"style":140},[475],{"type":23,"value":163},{"type":17,"tag":127,"props":477,"children":479},{"class":129,"line":478},13,[480,484],{"type":17,"tag":127,"props":481,"children":482},{"style":140},[483],{"type":23,"value":216},{"type":17,"tag":127,"props":485,"children":486},{"style":146},[487],{"type":23,"value":488},"./app:/var/www/html\n",{"type":17,"tag":127,"props":490,"children":492},{"class":129,"line":491},14,[493,497],{"type":17,"tag":127,"props":494,"children":495},{"style":140},[496],{"type":23,"value":216},{"type":17,"tag":127,"props":498,"children":499},{"style":146},[500],{"type":23,"value":501},"./certs/:/etc/ssl/private/\n",{"type":17,"tag":503,"props":504,"children":505},"note",{},[506],{"type":17,"tag":25,"props":507,"children":508},{},[509,511,517],{"type":23,"value":510},"Ensure your private key file is set to the permissions ",{"type":17,"tag":31,"props":512,"children":514},{"className":513},[],[515],{"type":23,"value":516},"600",{"type":23,"value":518}," (read/write for owner only). If you don't set the permissions correctly, you will run into errors with loading an insecure private key file.",{"type":17,"tag":25,"props":520,"children":521},{},[522,524,530,532,538,540,546],{"type":23,"value":523},"The above example provides the private and public key pair with ",{"type":17,"tag":31,"props":525,"children":527},{"className":526},[],[528],{"type":23,"value":529},"SSL_PRIVATE_KEY_FILE",{"type":23,"value":531}," and ",{"type":17,"tag":31,"props":533,"children":535},{"className":534},[],[536],{"type":23,"value":537},"SSL_CERTIFICATE_FILE",{"type":23,"value":539}," environment variables. The files are mounted to the container with the ",{"type":17,"tag":31,"props":541,"children":543},{"className":542},[],[544],{"type":23,"value":545},"volumes",{"type":23,"value":547}," directive.",{"type":17,"tag":25,"props":549,"children":550},{},[551],{"type":23,"value":552},"To give you a clearer picture of the project structure, this is what my folder looks like:",{"type":17,"tag":112,"props":554,"children":555},{"label":310},[556],{"type":17,"tag":117,"props":557,"children":560},{"className":558,"code":559,"language":23,"meta":7,"style":7},"language-text shiki shiki-themes github-dark github-dark monokai",".\n├── app\n│   └── public\n│       └── index.php\n├── certs\n│   ├── test-key.pem\n│   └── test.pem\n└── docker-compose.yml\n",[561],{"type":17,"tag":31,"props":562,"children":563},{"__ignoreMap":7},[564,572,580,588,596,604,612,620],{"type":17,"tag":127,"props":565,"children":566},{"class":129,"line":130},[567],{"type":17,"tag":127,"props":568,"children":569},{},[570],{"type":23,"value":571},".\n",{"type":17,"tag":127,"props":573,"children":574},{"class":129,"line":152},[575],{"type":17,"tag":127,"props":576,"children":577},{},[578],{"type":23,"value":579},"├── app\n",{"type":17,"tag":127,"props":581,"children":582},{"class":129,"line":166},[583],{"type":17,"tag":127,"props":584,"children":585},{},[586],{"type":23,"value":587},"│   └── public\n",{"type":17,"tag":127,"props":589,"children":590},{"class":129,"line":179},[591],{"type":17,"tag":127,"props":592,"children":593},{},[594],{"type":23,"value":595},"│       └── index.php\n",{"type":17,"tag":127,"props":597,"children":598},{"class":129,"line":197},[599],{"type":17,"tag":127,"props":600,"children":601},{},[602],{"type":23,"value":603},"├── certs\n",{"type":17,"tag":127,"props":605,"children":606},{"class":129,"line":210},[607],{"type":17,"tag":127,"props":608,"children":609},{},[610],{"type":23,"value":611},"│   ├── test-key.pem\n",{"type":17,"tag":127,"props":613,"children":614},{"class":129,"line":224},[615],{"type":17,"tag":127,"props":616,"children":617},{},[618],{"type":23,"value":619},"│   └── test.pem\n",{"type":17,"tag":127,"props":621,"children":622},{"class":129,"line":237},[623],{"type":17,"tag":127,"props":624,"children":625},{},[626],{"type":23,"value":627},"└── docker-compose.yml\n",{"type":17,"tag":25,"props":629,"children":630},{},[631,633,639,641,647,649,655],{"type":23,"value":632},"You can see the ",{"type":17,"tag":31,"props":634,"children":636},{"className":635},[],[637],{"type":23,"value":638},"docker-compose.yml",{"type":23,"value":640}," file is in the parent directory. The ",{"type":17,"tag":31,"props":642,"children":644},{"className":643},[],[645],{"type":23,"value":646},"app",{"type":23,"value":648}," directory is dedicated for all application files, where the ",{"type":17,"tag":31,"props":650,"children":652},{"className":651},[],[653],{"type":23,"value":654},"certs",{"type":23,"value":656}," directory is dedicated for all SSL certificates.",{"type":17,"tag":25,"props":658,"children":659},{},[660,662,668],{"type":23,"value":661},"The separation of these two directories is important. It would not be a good practice to mount your certificate files in the ",{"type":17,"tag":31,"props":663,"children":665},{"className":664},[],[666],{"type":23,"value":667},"/var/www/html",{"type":23,"value":669}," directory on a production machine.",{"type":17,"tag":503,"props":671,"children":672},{},[673],{"type":17,"tag":25,"props":674,"children":675},{},[676,678,687],{"type":23,"value":677},"For a signed certificate, you must acquire one from a trusted certificate authority (like ",{"type":17,"tag":679,"props":680,"children":684},"a",{"href":681,"rel":682},"https://www.ssls.com/",[683],"nofollow",[685],{"type":23,"value":686},"ssls.com",{"type":23,"value":688},").",{"type":17,"tag":690,"props":691,"children":693},"h3",{"id":692},"additional-options-for-nginx-unit",[694],{"type":23,"value":695},"Additional options for NGINX Unit",{"type":17,"tag":25,"props":697,"children":698},{},[699,701,707,709,715,717,724],{"type":23,"value":700},"If you're using NGINX Unit, you also have the option of setting ",{"type":17,"tag":31,"props":702,"children":704},{"className":703},[],[705],{"type":23,"value":706},"UNIT_CERTIFICATE_NAME",{"type":23,"value":708}," (default: ",{"type":17,"tag":31,"props":710,"children":712},{"className":711},[],[713],{"type":23,"value":714},"self-signed-web-bundle",{"type":23,"value":716},"). This is the name of the certificate bundle that will be used by NGINX Unit. You can read more about this in the ",{"type":17,"tag":679,"props":718,"children":721},{"href":719,"rel":720},"https://unit.nginx.org/configuration/#ssl-tls-configuration",[683],[722],{"type":23,"value":723},"NGINX Unit documentation",{"type":23,"value":725},".",{"type":17,"tag":78,"props":727,"children":729},{"id":728},"using-lets-encrypt",[730],{"type":23,"value":731},"Using Let's Encrypt",{"type":17,"tag":25,"props":733,"children":734},{},[735,737,744,745,752],{"type":23,"value":736},"If you'd like to use Let's Encrypt (what we use), it's best to use a reverse proxy like ",{"type":17,"tag":679,"props":738,"children":741},{"href":739,"rel":740},"https://traefik.io/traefik/",[683],[742],{"type":23,"value":743},"Traefik",{"type":23,"value":102},{"type":17,"tag":679,"props":746,"children":749},{"href":747,"rel":748},"https://caddyserver.com/",[683],[750],{"type":23,"value":751},"Caddy",{"type":23,"value":725},{"type":17,"tag":25,"props":754,"children":755},{},[756],{"type":23,"value":757},"Providing examples for those are out of the scope of this project, but we may consider adding examples in other projects in the future.",{"type":17,"tag":759,"props":760,"children":761},"style",{},[762],{"type":23,"value":763},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html.sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}",{"title":7,"searchDepth":152,"depth":152,"links":765},[766,767,770],{"id":80,"depth":152,"text":83},{"id":299,"depth":152,"text":302,"children":768},[769],{"id":692,"depth":166,"text":695},{"id":728,"depth":152,"text":731},"markdown","content:docs:5.customizing-the-image:4.configuring-ssl.md","content","docs/5.customizing-the-image/4.configuring-ssl.md","md",1727889428301]