0

Tengo esta configuración para un proyecto con PHP7, esta configuración funciona pero como podeis ver tengo el bloque duplicado para http y https, hay forma de unificar esto? He probado a eliminar el primer bloque y dejar el segundo entero con la configuración de

        #listen 80; <== activando esto, da error
        listen 443 ssl;
        server_name miserver.dominio.com;
        ssl_certificate    /etc/ssl/certs/test_wildcard_2020.pem;
        ssl_certificate_key  /etc/ssl/private/test_wildcard_2020.key;



server {
        listen 80;
    server_name miserver.dominio.com;

    root /var/www/html/site1/test1;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /404.html;
    error_page 505 /500.html;

    location = /404.html {
                root /var/www/html/errors;
                internal;
    }


    location = /500.html {
                root /var/www/html/errors;
                internal;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}


server {
        #listen 80;
        listen 443 ssl;
        server_name miserver.dominio.com;
        ssl_certificate    /etc/ssl/certs/test_wildcard_2020.pem;
        ssl_certificate_key  /etc/ssl/private/test_wildcard_2020.key;

    root /var/www/html/site1/test1;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }


    error_page 404 /404.html;
    error_page 505 /500.html;

    location = /404.html {
                root /var/www/html/errors;
                internal;
    }

    location = /500.html {
                root /var/www/html/errors;
                internal;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

1 respuesta 1

2

intenta de esta forma y deja los certificados de ssl al final del objeto server, usa sudo nginx -t para que te diga si tienes errores antes que reinicies el nginx

listen 80;
listen 443 ssl http2;
server_name .miserver.dominio.com;
root "/var/www/html/site1/test1";
1
  • Muchas gracias , a funcionado a la primera.
    – ilernet
    el 27 feb. 2020 a las 8:09

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.