Jump to content
  • 0

https и nginx


Vlad
 Share

Question

На сервере используется Nginx и в конфиге стоит автоматическое перенаправление на https.

listen 185.5.248.232:80;
return 301 https://$host:443$request_uri;

Мне понадобилось сделать поддомен sub.site.ru, на котором должен быть обычный http. Подскажите, как сделать правильно перенаправление этого поддомена на версию с http, а не https?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

ну я себе настраивал следующим образом:

В сервер-блоке для основного http домена идет редирект на https

server {
    listen 80;
    server_name blabla.com;
    return 301 https://blabla.com$request_uri;
}
server {
    listen 443 ssl;
    server_name blabla.com;
    
    resolver 8.8.8.8;
    ssl on;
    # И еще большой кусок конфига ssl
    
    root /path/to/blabla.com/www/public/;
    error_page 404 /404.php;
    error_page 403 /403.php;
    access_log /path/to/blabla.com/logs/access.log;
    error_log /path/to/blabla.com/logs/error.log;
    index index.php index.html;

    try_files $uri $uri/ /index.php?$query_string;

    location ~ .*.php$ {
        include fastcgi_params;
        fastcgi_pass localhost:9000;
        fastcgi_index index.php;
    }
    location ~*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
    }
    location ~*\.(?:css|js|woff|ttf)$ {
        expires 1y;
        access_log off;
        add_header Cache-Control "public";
    }
    location ~ /\.ht {
        deny all;
    }
}

Для поддомена свой еще сервер-блок

server {
    listen 80;
    server_name ts.blabla.com;

    root /path/to/ts.blabla.com/www/;
    error_page 404 /404.html;
    error_page 403 /403.html;
    access_log /path/to/ts.blabla.com/logs/access.log;
    error_log /path/to/ts.blabla.com/logs/error.log;
    index index.php index.html;
    
    try_files $uri $uri/ =404;

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

    location ~ .*.php$ {
        include fastcgi_params;
        fastcgi_pass localhost:9000;
        fastcgi_index index.php;
    }
    location ~*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
    }
    location ~*\.(?:css|js|woff|ttf)$ {
        expires 1y;
        access_log off;
        add_header Cache-Control "public";
    }
    location ~ /\.ht {
        deny all;
    }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy