页面: 1
原文:http://blog.mindcont.com/2016/12/26/nginx-proxy-lan/
1、登录OpenWrt 安装nginx
在windows下使用SSH工具,如Putty等,在Host name 填写192.168.1.1,端口22 ,然后点击 Open.
使用opkg安装 nginx ,输入下面的指令
opkg update
opkg install nginx2、配置 nginx
这里我们首先将nginx原本配置文件nginx.conf备份为nginx.conf.backup,后修改里面的内容,配置为HTTP反向代理模式,选择8080为服务监听端口。
cd /etc/nginx
cp nginx.conf nginx.conf.backup
vi nginx.conf将下面的内容替换nginx.conf中默认的内容
user nobody nogroup;
worker_processes 1;
events {
worker_connections 1024;
}
http {
#include mime.types;
#default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
#include /etc/nginx/conf.d/*.conf;
resolver 114.114.114.114;
server {
listen 8080;
location / {
proxy_pass $scheme://$http_host$request_uri;
}
}
}修改完成后,按 esc ,输入:wq! 保存
紧接着,启动nginx
cd /etc/init.d
./nginx start浏览器就可以设置openwrt 的ip地址,端口为:8080上网了。
离线
页面: 1