Jelenlegi hely

Apache, Nginx HTTPS redirect

Apache, Nginx HTTPS redirect

Forrás: https://www.digitalocean.com/community/questions/redirect-from-http-to-h...

APACHE:

< VirtualHost *:80 >
ServerName example.com
Redirect / https://example.com/
< /VirtualHost >


< VirtualHost *:80 >
ServerName sub.example.org
DocumentRoot /var/www/sub
DirectoryIndex index.php
< Directory /var/www/sub/ >
AllowOverride All
Order Deny,Allow
Allow from all
< /Directory >
RewriteEngine on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
< /VirtualHost >


< IfModule mod_ssl.c >
< VirtualHost *:443 >
ServerName sub.example.org
DocumentRoot /var/www/sub
DirectoryIndex index.php
< Directory /var/www/sub/ >
AllowOverride All
Order Deny,Allow
Allow from all
< /Directory >
SSLCertificateFile /etc/letsencrypt/live/sub.example.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sub.example.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/sub.example.org/chain.pem
< /VirtualHost >
< /IfModule >

NGINX:

server {
listen 80;
server_name .example.com;

location / {
rewrite ^(.*) https://example.com$request_uri;
}
}

server {
listen {IP}:443 ssl;
server_name example.com;
ssl_certificate /etc/ssl/certs/example.com/example_com.crt;
ssl_certificate_key /etc/ssl/certs/example.com/example.com.key;

root "/var/www/example.com";
error_log "/var/log/nginx/error.example.com.log";

location / {
try_files $uri $uri/ index.html;
}
}

Theme by me