Last active
November 8, 2024 02:23
-
-
Save charlesrc019/3754806b60e017cfeb45b0f299cf7c38 to your computer and use it in GitHub Desktop.
server_config_dual_http_and_https.nginx
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
# Default | |
server { | |
server_name dev1.simplifize.co; | |
root /var/www/html; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name _; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
# process PHP | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php8.1-fpm.sock; # php-fpm | |
# fastcgi_pass 127.0.0.1:9000; # php-cgi | |
} | |
# deny access to .htaccess | |
location ~ /\.ht { | |
deny all; | |
} | |
# SSL | |
listen [::]:443 ssl ipv6only=on; | |
listen 443 ssl; | |
ssl_certificate /etc/letsencrypt/live/dev1.simplifize.co/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/dev1.simplifize.co/privkey.pem; | |
include /etc/letsencrypt/options-ssl-nginx.conf; | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; | |
} | |
# Virtual | |
server { | |
# force redirect to HTTPS if via hostname | |
if ($host = dev1.simplifize.co) { | |
return 301 https://$host$request_uri; | |
} | |
root /var/www/html; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name _; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
# process PHP | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php8.1-fpm.sock; # php-fpm | |
# fastcgi_pass 127.0.0.1:9000; # php-cgi | |
} | |
# deny access to .htaccess | |
location ~ /\.ht { | |
deny all; | |
} | |
listen 80; | |
listen [::]:80; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment