added https support

This commit is contained in:
mohd
2024-05-14 16:59:00 +03:00
parent 8f7ddedd0d
commit 33a2253e3d
3 changed files with 48 additions and 83 deletions
+46 -82
View File
@@ -32,76 +32,14 @@ http {
#gzip on;
server {
listen 80;
server_name localhost;
server {
listen 80;
server_name hsmod.xyz www.hsmod.xyz; # Change to your actual domain
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9002;
}
location /static/ {
root /usr/local/web;
if (-f $request_filename) {
rewrite ^/static/(.*)$ /static/$1 break;
}
}
#location / {
# root html;
# index index.html index.htm;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location / {
return 301 https://$host$request_uri;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
@@ -119,23 +57,49 @@ http {
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
server {
listen 443 ssl;
server_name hsmod.xyx www.hsmod.xyz; # Change to your actual domain
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
ssl_certificate /app/letsencrypt/fullchain.pem; # Path to fullchain.pem
ssl_certificate_key /app/letsencrypt/privkey.pem; # Path to privkey.pem
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
ssl_dhparam /app/letsencrypt/ssl-dhparams.pem;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# FastCGI settings retained from your original config
location / {
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9002;
}
# Setup for serving static files
location /static/ {
root /app/hm_nginx/../hm_web/;
try_files $uri $uri/ =404;
}
# Error pages configuration
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}