nginx配置(三)重定向实例

    xiaoxiao2021-03-25  128

    实现80进来的请求,重定向为https

    方法一:在http的server里增加

    rewrite   ^(.*) https://$host$1 permanent;

    方法二:通过497错误页面(可以实现非80端口的跳转)

    error_page 497 https://$host:$server_port$request_uri;                                                                           if ($scheme = http){   return 497;      }

    其中:$server_port, 请求到达的服务器端口号;

              $scheme, 所用的协议,比如http或者是https,         

    只输入IP和端口即跳转到前端页面

    location / {             include uwsgi_params;             uwsgi_pass unix:****;             rewrite ^/$ /static/index.html redirect;         }

    访问/app路由即跳转到指定网址

    location ^~ /app {       rewrite ^/  https://*****;      }

    转载请注明原文地址: https://ju.6miu.com/read-12435.html

    最新回复(0)