vitodeploy / vito

The Ultimate Server Management Tool
https://vitodeploy.com
GNU Affero General Public License v3.0
1.07k stars 166 forks source link

Force HTTPS configuration for sites #303

Open saeedvaziry opened 5 days ago

saeedvaziry commented 5 days ago

Discussed in https://github.com/vitodeploy/vito/discussions/275

Originally posted by **agustinzamar** August 14, 2024 I already deploployed a site and created a ssl certificate for it. How can I force redirect to https site when the user access to http? I tried manually updating the vhost but if there are any changes it will get reset I believe
ShaniHakir commented 3 days ago

Discussed in #275

Originally posted by agustinzamar August 14, 2024 I already deploployed a site and created a ssl certificate for it. How can I force redirect to https site when the user access to http? I tried manually updating the vhost but if there are any changes it will get reset I believe

I noticed that you are setting up port 80 and 443 in the same server block in nginx: app/SSH/Services/Webserver/scripts/nginx/php-vhost-ssl.conf

but for the redirect to work you need to make separate block for port 80, and then if port 80 is called issue a redirect to 443, like this

server {
    listen 80;
    server_name **domain** **aliases**;
    return 301 https://$server_name$request_uri;
}

# HTTPS server block
server {
    listen 443 ssl;
    ........etc