yisier / nps

基于NPS 0.29.10 版本二开而来,NPS接力项目。公益云NPS:https://natnps.com
GNU General Public License v3.0
2.02k stars 256 forks source link

可以添加http重定向到https吗 #30

Closed xuanpro closed 8 months ago

xuanpro commented 1 year ago

域名解析只打开https的时候,希望通过https进行访问,可以添加http重定向https吗。nps管理页面也希望有重定向

yisier commented 1 year ago

拿nginx 举例,如果只穿透https端口,访问80时,会报 状态码:497 HTTP Request Sent to HTTPS Port 发送到HTTPS端口请求

可以设置nginx 自动跳转到https,参考下nginx的配置

server {
        listen 443 ssl;
        server_name www.xxx.com;
        error_page  497 https://$http_host$request_uri;  # 重点在这里,只需要一行配置

        ssl_certificate /usr/local/nginx/cert/7172296_www.xxx.com.pem;
        ssl_certificate_key /usr/local/nginx/cert/7172296_www.xxxx.com.key; 
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

         location / {
            root   html;
            index  index.html index.htm;
        }

        error_page 500 502 503 504 /50x.html;
    }
xuanpro commented 1 year ago

并不是nginx,而且是用的域名解析的证书,就比如说nps的管理页面就不能自动跳转

gisxlab commented 1 year ago

请教web管理页https怎么配置呀?

教程:如果web管理需要使用https,可以在配置文件nps.conf中设置web_open_ssl=true,并配置web_cert_file和web_key_file

web_host=nps.mydomain.com web_username=admin web_password=123456 web_port = 10088 web_ip=0.0.0.0 web_base_url= web_open_ssl=true web_cert_file=conf/server.pem web_key_file=conf/server.key`