设为首页收藏本站

简体中文 繁體中文 English 日本語 Deutsch 한국 사람 بالعربية TÜRKÇE português คนไทย Français

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
楼主: cjf051

nginx的https如何跳转到其他url?

[复制链接]

0

主题

1

回帖

4

积分

新手上路

积分
4
发表于 2017-5-31 15:53:58 | 显示全部楼层

冻猫 发表于 2017-5-31 15:57

https的要写在下面那个server 443端口里面啊。你写80端口这里肯定不会跳转。

写在那里的话能跳,但是提示重定向太多,无法访问了 本帖最后由 aboutyj 于 2017-5-31 16:05 编辑

如下:但是我想说,谁TM会闲的蛋疼https://domain.com这样去访问啊?这么有空去手输https://?习惯的都是直接在地址栏输domain.com这样吧?然后浏览器自动补齐成http://domain.com然后跳转

[ol]
  • vim /your-conf-path/your-conf.conf
  • server {
  •     listen 80;
  •     server_name domain.com;
  •     return 301 https://www.domain.com$request_uri;
  • }
  • server {
  •     listen 80;
  •     server_name www.domain.com;
  •     return 301 https://www.domain.com$request_uri;
  • }
  • server {
  •     listen 443 ssl;
  •     server_name domain.com;
  •     ssl_certificate /your-sslca-path/domain.crt;
  •     ssl_certificate_key /your-sslca-path/domain.key;
  •     return 301 https://www.domain.com$request_uri;
  • }
  • server {
  •     listen 443 ssl;
  •     server_name www.domain.com;
  •     charset utf-8;
  •     ssl on;
  •     ssl_certificate /your-sslca-path/domain.crt;
  •     ssl_certificate_key /your-sslca-path/domain.key;
  •     ssl_session_timeout  60m;
  •     ssl_protocols  SSLv2 SSLv3 TLSv1;
  •     ssl_ciphers  ALL:!ADH:!EXPOR***56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
  •     ssl_prefer_server_ciphers   on;
  •     add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
  •     location / {
  •         ......
  •     }
  • ......
  • }[/ol]复制代码
  • 回复

    使用道具 举报

    23

    主题

    558

    回帖

    1241

    积分

    金牌会员

    积分
    1241
    发表于 2017-5-31 15:54:53 | 显示全部楼层
    我自己用的你看看,我直接lnmp生成的改的
    [ol]
  • server
  •         {  
  •     listen 80;  
  •     server_name www.domain.com domain.com;  
  •     rewrite ^(.*)$  https://www.domain.com/$1 permanent;  
  •         }  
  • server
  •     {
  •         #listen 80;
  •         #listen [::]:80;
  •                 listen 443;
  •                
  •                 ssl on;
  •                 ssl_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem;
  •                 ssl_certificate_key /etc/letsencrypt/live/www.domain.com/privkey.pem;
  •                 ssl_trusted_certificate /etc/letsencrypt/live/www.domain.com/root_ca_cert_plus_intermediates;
  •                 ssl_session_timeout  5m;
  •         server_name www.domain.com domain.com;
  •         index index.html index.htm index.php default.html default.htm default.php;
  •         root  /home/wwwroot/domain.com;
  •                 if ($host = 'domain.com')
  •                 {
  •            rewrite ^/(.*)$ https://www.domain.com/$1 permanent;
  •         }
  •         include wordpress.conf;
  •         #error_page   404   /404.html;
  •         include enable-php.conf;
  •                
  •         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  •         {
  •             expires      30d;
  •         }
  •         location ~ .*\.(js|css)?$
  •         {
  •             expires      12h;
  •         }
  •         location ~ /\.
  •         {
  •             deny all;
  •         }
  •         access_log  /home/wwwlogs/domain.com.log;
  •     }
  • [/ol]复制代码
  • 回复

    使用道具 举报

    13

    主题

    918

    回帖

    1965

    积分

    金牌会员

    积分
    1965
    发表于 2017-5-31 15:55:07 | 显示全部楼层
    [ol]
  • server {
  •   listen 80;
  •   listen 443 ssl;
  •   ssl_certificate crt;
  •   ssl_certificate_key key;
  •   add_header Strict-Transport-Security max-age=15768000;
  •   server_name www.domain.com domain.com;
  •   index index.html index.htm index.php;
  •   root /domain.com;
  •   if ($ssl_protocol = "") { return 301 https://$server_name$request_uri; }
  • [/ol]复制代码

    直接写在一个server里面。把你的80和443
  • 回复

    使用道具 举报

    55

    主题

    857

    回帖

    1935

    积分

    金牌会员

    积分
    1935
    发表于 2017-5-31 15:56:12 | 显示全部楼层
    "

    大佬,我用你这个可以跳https,不过和楼主情况一样,https好像跳不了!
    回复

    使用道具 举报

    49

    主题

    1271

    回帖

    2695

    积分

    金牌会员

    积分
    2695
    发表于 2017-5-31 15:57:07 | 显示全部楼层
    网页文件跳转
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2026-6-19 09:54 , Processed in 0.016588 second(s), 3 queries , Gzip On, Redis On.

    Powered by Discuz! X5.0

    © 2001-2026 Discuz! Team.

    快速回复 返回顶部 返回列表