Nginx : redirections 301 plusieurs domaines.

Discussion dans 'Administration d'un site Web' créé par ortolojf, 4 Novembre 2018.

  1. ortolojf
    ortolojf WRInaute accro
    Inscrit:
    14 Août 2002
    Messages:
    2 864
    J'aime reçus:
    10
    Bonjour

    J'ai un VPS OVH SSD Classic 2016.

    Sous Nginx ( index spécifiés dans /etc/nginx/nginx.conf ), je cherche à redirectionner en 301 quelques ndds vers mon site https://www.pronostics-courses.fr

    Je lance le pronostics-courses.fr avec et sans www en https, çà marche.

    Avec http://pronostics-courses.fr ( sans sous avec www ), erreur.

    Avec : www.ortolojf-courses.com ( idem ) çà ne marche pas.

    Pourquoi ?

    Merci beaucoup de vos réponses.

    Respectueusement.



    Code:
    
    ###############################################
    #
    # /etc/nginx/sites-available/ortolojf-courses.com.conf
    #
    ###############################################
    server {
        listen    54.37.65.148:80;
        listen [::]:80;
    #    listen [2001:41d0:0401:3200:0000:0000:0000:2971]:80;
        root /var/www/html;
        # Add index.php to the list if you are using PHP
        # index index.php index.html index.htm;
        server_name ortolojf-courses.com www.ortolojf-courses.com;
        include php.conf;
        return 301 https://www.pronostics-courses.fr$request_uri;
    }
    
    
    #####################################################
    #
    # /etc/nginx/sites-available/pronostics-courses.fr.conf
    #
    #####################################################
    server {
        listen    54.37.65.148:80;
        listen    [::]:80;
    #    listen [2001:41d0:0401:3200:0000:0000:0000:2971]:80;
        server_name pronostics-courses.fr www.pronostics-courses.fr;
        root    /var/www/html;
        # index index.php index.html;
    #    access_log    /var/log/nginx/pronostics-courses.fr/access.log;
    #    error_log     /var/log/nginx/pronostics-courses.fr/error.log;
        location ~ /.well-known {
            root    /var/www/letsencrypt/pronostics-courses.fr;
            allow all;
        }
        include php.conf;
        # Redirection http vers https
        return 301    https://www.pronostics-courses.fr$request_uri;
    }
    server {
        listen    54.37.65.148:443 ssl http2;
        listen [::]:443 ssl http2;
    #    listen [2001:41d0:0401:3200:0000:0000:0000:2971]:443 ssl http2;
        server_name  pronostics-courses.fr;
        root /var/www/html;
        # index index.php index.html;
        location ~ /.well-known {
            root    /var/www/letsencrypt/pronostics-courses.fr;
            allow all;
        }
        include php.conf;
            rewrite ^ https://www.pronostics-courses.fr$request_uri permanent;
    #    add_header    Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
        add_header    X-Content-Type-Options nosniff;
        add_header    X-Frame-Options SAMEORIGIN;
        add_header    X-XSS-Protection "1; mode=block";
        add_header     Content-Security-Policy "default-src 'none'; form-action 'self'; script-src 'self' https://analytics.pronostics-courses.fr 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' data:; img-src 'self' https://analytics.pronostics-courses.fr data:; font-src 'self'; child-src 'self' https://analytics.pronostics-courses.fr; frame-src 'self' https://analytics.pronostics-courses.fr; connect-src 'self'; frame-ancestors 'none';";
        #### SSL
        ssl_certificate /etc/letsencrypt/live/www.pronostics-courses.fr/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/www.pronostics-courses.fr/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/www.pronostics-courses.fr/fullchain.pem;
        ssl_dhparam /etc/nginx/ssl/private/dhparam_4096.pem;
        # ssl_ecdh_curve chiffrement_edch_choisi;
        ssl_prefer_server_ciphers on;
        # Intermediate Mode
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        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:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
        # More secure Mode
        #ssl_ciphers 'ECDH:DH:AES:!aNULL:!eNULL:!NULL:!DES:!3DES:!DSS:!EXPORT:!LOW:!MEDIUM:!PSK:!RC4:!SHA';
        ssl_session_cache shared:SSL:10m;
        ssl_session_tickets on;
        ssl_session_ticket_key /etc/nginx/ssl/ticket.key;
        ssl_session_timeout 24h;
        ssl_stapling on;
        ssl_stapling_verify on;
        #resolver 127.0.0.1;
        # resolvers FDN, OpenNIC
        resolver 80.67.169.12 80.67.169.40 142.4.204.111 142.4.205.47 valid=300s;
        # resolver ipv6 : FQDN
        # resolver 2001:910:800::12 2001:910:800::40 valid=300s;
        resolver_timeout 3s;
    }
    # Notre bloc serveur
    server {
        listen    54.37.65.148:443 ssl http2;
        listen [::]:443 ssl http2;
    #    listen [2001:41d0:0401:3200:0000:0000:0000:2971]:443 ssl http2;
        server_name www.pronostics-courses.fr;
        root /var/www/html;
        # index index.php index.html;
        access_log    /var/log/nginx/pronostics-courses.fr/ssl_access.log;
        error_log     /var/log/nginx/pronostics-courses.fr/ssl_error.log;
    #    rewrite_log on;
        location ~ /.well-known {
            root    /var/www/letsencrypt/pronostics-courses.fr;
            allow all;
        }
        add_header x-dns-prefetch-control on;
        location /php/courses_nouvelles/mode_demploi_4.html {
            expires 30d;
        }
        location /php/courses_actuellles/mode_demploi_4.html {
            expires 30d;
        }
        location /php/courses_anciennes/mode_demploi_4.html {
            expires 30d;
        }
        ####    Locations
        # On cache les fichiers statiques
        location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|eot|woff|ttf)$ {
            expires max;
        }
        # On interdit les dotfiles
        #location ~ /\. {
        #    deny all;
        #}
        include php.conf;
        include default_nginx_ssl.conf;
        include drop.conf;
        add_header x-dns-prefetch-control on;
    #    add_header    Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
        add_header    X-Content-Type-Options nosniff;
        add_header    X-Frame-Options SAMEORIGIN;
        add_header    X-XSS-Protection "1; mode=block";
        add_header     Content-Security-Policy "default-src 'none'; form-action 'self'; script-src 'self' https://analytics.pronostics-courses.fr 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' data:; img-src 'self' https://analytics.pronostics-courses.fr data:; font-src 'self'; child-src 'self' https://analytics.pronostics-courses.fr; frame-src 'self' https://analytics.pronostics-courses.fr; connect-src 'self'; frame-ancestors 'none';";
        #### SSL
        ssl_certificate /etc/letsencrypt/live/www.pronostics-courses.fr/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/www.pronostics-courses.fr/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/www.pronostics-courses.fr/fullchain.pem;
        ssl_dhparam /etc/nginx/ssl/private/dhparam_4096.pem;
        # ssl_ecdh_curve chiffrement_edch_choisi;
        ssl_prefer_server_ciphers on;
        # Intermediate Mode
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        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:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
        # More secure Mode
        #ssl_ciphers 'ECDH:DH:AES:!aNULL:!eNULL:!NULL:!DES:!3DES:!DSS:!EXPORT:!LOW:!MEDIUM:!PSK:!RC4:!SHA';
        ssl_session_cache shared:SSL:10m;
        ssl_session_tickets on;
        ssl_session_ticket_key /etc/nginx/ssl/ticket.key;
        ssl_session_timeout 24h;
        ssl_stapling on;
        ssl_stapling_verify on;
        #resolver 127.0.0.1;
        # resolvers FDN, OpenNIC
        resolver 80.67.169.12 80.67.169.40 142.4.204.111 142.4.205.47 valid=300s;
        # resolver ipv6 : FQDN
        # resolver 2001:910:800::12 2001:910:800::40 valid=300s;
        resolver_timeout 3s;
     }
    
    
    
    
     
  2. ortolojf
    ortolojf WRInaute accro
    Inscrit:
    14 Août 2002
    Messages:
    2 864
    J'aime reçus:
    10
    Et puis...

    Dans les fichiers de confguration, je met le fichier php.conf :

    Merci de me dire où çà coince ? ;)

    Respectueusement.


    Code:
    
    #
    ###########################################
    #  /etc/nginx/php.conf
    ###########################################
    #
    location ~ \.php {
            # for security reasons the next line is highly encouraged
    #        try_files $uri =404;
    #    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            # if the next line in yours still contains $document_root
            # consider switching to $request_filename provides
            # better support for directives such as alias
            fastcgi_param  SCRIPT_FILENAME    $request_filename;
        fastcgi_param  QUERY_STRING       $query_string;
        fastcgi_param  REQUEST_METHOD     $request_method;
        fastcgi_param  CONTENT_TYPE       $content_type;
        fastcgi_param  CONTENT_LENGTH     $content_length;
        fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
        fastcgi_param  REQUEST_URI        $request_uri;
        fastcgi_param  DOCUMENT_URI       $document_uri;
        fastcgi_param  DOCUMENT_ROOT      $document_root;
        fastcgi_param  SERVER_PROTOCOL    $server_protocol;
        fastcgi_param  REQUEST_SCHEME     $scheme;
        fastcgi_param  HTTPS              $https if_not_empty;
        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;
        # PHP only, required if PHP was built with --enable-force-cgi-redirect
        fastcgi_param  REDIRECT_STATUS    200;
        fastcgi_intercept_errors    on;
            # If using a unix socket...
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            # If using a TCP connection...
            #fastcgi_pass 127.0.0.1:9000;
        fastcgi_read_timeout 1200;
    }
    
    
     
Chargement...
Similar Threads - Nginx redirections 301 Forum Date
Plan de redirections 301 / Serveur nginx Débuter en référencement 9 Janvier 2018
Nginx et redirection d'url avec extensions .php URL Rewriting et .htaccess 22 Octobre 2018
redirection en gardant l'url sous nginx URL Rewriting et .htaccess 11 Janvier 2018
Comment cacher des scripts Javascript distants sous Nginx ? Développement d'un site Web ou d'une appli mobile 29 Octobre 2017
Problème d'url-rewriting sous Nginx Développement d'un site Web ou d'une appli mobile 16 Août 2016
Plesk et nginx Administration d'un site Web 23 Décembre 2015
Pagespeed bientôt en module Nginx ? Administration d'un site Web 19 Décembre 2015
configurer nginx /usr/share/nginx Administration d'un site Web 16 Décembre 2015
Nginx + Pagespeed => pas de connexion https ? Administration d'un site Web 13 Décembre 2015
Apache + mod-pagespeed ou Nginx compilé ? Administration d'un site Web 7 Décembre 2015
  1. Ce site utilise des cookies. En continuant à utiliser ce site, vous acceptez l'utilisation des cookies.
    Rejeter la notice