找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 2996|回复: 1

关于路由器设置ngnix反向代理,监听端口实现http跳转https访问网络的问题

[复制链接]
本帖最后由 clion007 于 2017-6-13 19:55 编辑

如题,我之前写了一个脚本https://www.right.com.cn/forum/thread-217335-1-1.html,可以通过dnsmasq重指向,访问墙外的网站,只是每次都要手动将http的地址链接改为https的链接才能访问,尤其是手机等客户端接入访问时,很是不方便。以前看到老毛子的固件里面有一项HTTP WEB服务的功能,可以指定web服务协议为https,端口443。但是在openwrt系列固件中,没有见到过,不知道是哪个软件。之前看一篇网友的帖子提到,可以通过ngnix反向代理,监听端口443,rewrite命令,通过所监听的端口访问时,实现http自动跳转为https的书写格式网址,从而正常访问指定的网络。但是我尝试了很多次,都没有效果。不知道应该如何配置,请知道的网友告知一下。不胜感激!

我现在用的pandorabox最新稳定版的固件,并且已经安装了ngnix软件包,安装过程中提示80端口被占用,错误代码125,不知道有没有影响,ngnix.conf相关的配置如下:

  1. user nobody nogroup;
  2. worker_processes  1;

  3. #error_log  logs/error.log;
  4. #error_log  logs/error.log  notice;
  5. #error_log  logs/error.log  info;

  6. #pid        logs/nginx.pid;


  7. events {
  8.     worker_connections  1024;
  9. }


  10. http {
  11.     include       mime.types;
  12.     #default_type  application/octet-stream;

  13.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  14.     #                  '$status $body_bytes_sent "$http_referer" '
  15.     #                  '"$http_user_agent" "$http_x_forwarded_for"';

  16.     #access_log  logs/access.log  main;

  17.     sendfile        on;
  18.     #tcp_nopush     on;

  19.     #keepalive_timeout  0;
  20.     keepalive_timeout  65;

  21.     #gzip  on;

  22.     server {
  23.         listen       80;
  24.         server_name  localhost;

  25.         #charset koi8-r;

  26.         #access_log  logs/host.access.log  main;

  27.         location / {
  28.             root   html;
  29.             index  index.html index.htm;
  30.         }

  31.         #error_page  404              /404.html;

  32.         # redirect server error pages to the static page /50x.html
  33.         #
  34.         error_page   500 502 503 504  /50x.html;
  35.         location = /50x.html {
  36.             root   html;
  37.         }

  38.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  39.         #
  40.         #location ~ \.php$ {
  41.         #    proxy_pass   http://127.0.0.1;
  42.         #}

  43.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  44.         #
  45.         #location ~ \.php$ {
  46.         #    root           html;
  47.         #    fastcgi_pass   127.0.0.1:9000;
  48.         #    fastcgi_index  index.php;
  49.         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  50.         #    include        fastcgi_params;
  51.         #}

  52.         # deny access to .htaccess files, if Apache's document root
  53.         # concurs with nginx's one
  54.         #
  55.         #location ~ /\.ht {
  56.         #    deny  all;
  57.         #}
  58.     }


  59.     # another virtual host using mix of IP-, name-, and port-based configuration
  60.     #
  61.     #server {
  62.     #    listen       8000;
  63.     #    listen       somename:8080;
  64.     #    server_name  somename  alias  another.alias;

  65.     #    location / {
  66.     #        root   html;
  67.     #        index  index.html index.htm;
  68.     #    }
  69.     #}


  70.     # HTTPS server
  71.    
  72.     server {
  73.         listen       443;
  74.         server_name  localhost;
  75.         rewrite ^(.*)$  https://$host$1 permanent;
  76.     #    ssl                  on;
  77.     #    ssl_certificate      cert.pem;
  78.     #    ssl_certificate_key  cert.key;

  79.     #    ssl_session_timeout  5m;

  80.     #    ssl_protocols  SSLv2 SSLv3 TLSv1;
  81.     #    ssl_ciphers  HIGH:!aNULL:!MD5;
  82.     #    ssl_prefer_server_ciphers   on;

  83.         location / {
  84.             root   html;
  85.             index  index.html index.htm;
  86.         }
  87.     }

  88. }
复制代码

默认的https那里全是被注释掉的。我取消了相干的注释,并添加了红色的rewrite代码。但是测试没有效果。请高手指教一下!

或者如果openwrt中,有类似老毛子固件中那种http web服务功能的软件包,实现所有访问都自动跳转走443端口https安全链接访问功能也可以。如下图:


我的恩山、我的无线 The best wifi forum is right here.
马克---------------------------
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 01:43

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

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