Skip to content

Commit

Permalink
Add NginX example configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaury committed Dec 10, 2024
1 parent b65e2d9 commit e8a8041
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/dpk_pkg-post_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ else
pushd /opt/Temma > /dev/null
cp bin/comma /opt/temma-project-web/bin/
cp etc/apache.conf /opt/temma-project-web/etc/
cp etc/nginx.conf /opt/temma-project-web/etc/
cp etc/temma.php /opt/temma-project-web/etc/
cp etc/temma-full.php /opt/temma-project-web/etc/
cp -a etc/asynk /opt/temma-project-web/etc/
Expand Down Expand Up @@ -81,6 +82,7 @@ else
pushd /opt/Temma > /dev/null
cp bin/comma /opt/temma-project-api/bin/
cp etc/apache.conf /opt/temma-project-api/etc/
cp etc/nginx.conf /opt/temma-project-api/etc/
cp etc/temma-api.php /opt/temma-project-api/etc/temma.php
cp etc/temma-full.php /opt/temma-project-api/etc/
cp -a etc/asynk /opt/temma-project-api/etc/
Expand Down
83 changes: 83 additions & 0 deletions etc/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Nginx configuration example
# @author Amaury Bouchard <[email protected]>
# @copyright © 2024, Amaury Bouchard
# @link https://www.temma.net/documentation/installation#doc-nginx-server

# http://mysite.com
server {
listen 80;
server_name mysite.com;
return 301 https://www.mysite.com$request_uri;
}
# http://www.mysite.com
server {
listen 80;
server_name www.mysite.com;

# HTTPS redirection if the SSL certificate exists
if (-f /etc/letsencrypt/live/mysite.com/cert.pem) {
return 301 https://www.mysite.com$request_uri;
}

# configuration without SSL certificate
root /home/http/mysite.com/www;
index index.php index.html;
# root directory configuration
location / {
try_files $uri $uri/ /index.php/$uri;
}
# PHP handling with PHP-FPM
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# adjust to your PHP version and socket path
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
}
# logs
error_log /var/log/nginx/www.mysite.com-error.log warn;
access_log /var/log/nginx/www.mysite.com-access.log combined;
}
# https://mysite.com
server {
listen 443 ssl http2;
server_name mysite.com;

# SSL configuration
ssl_certificate /etc/letsencrypt/live/mysite.com/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# redirection
return 301 https://www.mysite.com$request_uri;
}
# https://www.mysite.com
server {
listen 443 ssl;
server_name www.mysite.com;

root /home/http/mysite.com/www;
index index.php index.html;

# SSL Configuration
ssl_certificate /etc/letsencrypt/live/mysite.com/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# root directory configuration
location / {
try_files $uri $uri/ /index.php/$uri;
}
# PHP handling with PHP-FPM (using UNIX socket or network socket)
location ~ \.php$ {
# UNIX socket configuration (adjust to your PHP version and socket path)
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
# network socket configuration (adjust to your PHP-FPM setup as needed)
#include fastcgi_params;
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# logs
error_log /var/log/nginx/www.mysite.com-error.log warn;
access_log /var/log/nginx/www.mysite.com-access.log combined;
}

0 comments on commit e8a8041

Please sign in to comment.