2

我正在用 Shibby FW 的 Tomato 配置我的家用路由器 ASUS N18U。我想在上面设置一个家庭网络服务器 NGINX。我知道,这并不理想。我唯一的问题是我无法从 Wan 访问服务器。此外,我有动态 IP,我已经通过 DDNS 服务解决了这个问题。如果我想访问路由器或 SFTP 的配置页面,或者当我输入 myddnsdomain 并且我在 LAN 内时,它工作正常。我在我的调制解调器上打开了端口 80(来自 ISP)并将下面的代码添加到路由器(ASUS N18U)配置中,我不能只在管理菜单中端口转发它,因为它只允许转发到局域网(我的网络服务器在“路由器”上)。

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

iptables -I 输入 -p tcp --dport 80 -j 接受

iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT

这些都没有解决我的问题。我也尝试过不同的端口。我对其进行了跟踪路由,似乎该路由器阻止了它。通过 Wan IP 访问我的服务器没有帮助。文件夹“www”不属于任何人。谢谢您的帮助

# NGinX generated config file
user    nobody;
worker_processes        1;
worker_cpu_affinity     0101;
master_process  off;
worker_priority 10;
error_log       /tmp/var/log/nginx/error.log;
pid     /tmp/var/run/nginx.pid;
worker_rlimit_nofile    8192;
events {
        worker_connections      512;
        }
http {
include /tmp/etc/nginx/mime.types;
include /tmp/etc/nginx/fastcgi.conf;
default_type    application/octet-stream;
log_format   main '$remote_addr - $remote_user [$time_local]  $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile        on;
client_max_body_size    100M;

server {
listen  80;
server_name     mydynamicdomain.net;
access_log      /tmp/var/log/nginx/access.log   main;
location        /       {
root    /tmp/mnt/CORSAIR/www;
index   index.html      index.htm       index.php;
error_page 404  /404.html;
error_page 500  502     503     504     /50x.html;
location        /50x.html       {
root    /tmp/mnt/CORSAIR/www;

4

3 回答 3

3

解决了

这个例子将对你有所帮助,因为我通过以下 iptable 规则实现了这一点

动态值:( 根据您的环境值更改)

广域网接口: vlan10 局域网接口: br0

LAN Web 服务器 IP: 192.168.1.1 LAN Web 服务器 端口: 8080

路由器 WAN IP: 192.168.10.129 路由器 LAN IP192.168.1.254

使用上述值插入以下规则:

1. 端口转发规则

iptables -I FORWARD 1 -i vlan10 -p tcp -d 192.168.1.1 --dport 8080 -j ACCEPT    
iptables -A PREROUTING -t nat -i vlan10 -p tcp --dport 8080 -j DNAT --to 192.168.1.1

2.NAT环回规则

iptables -t nat -A PREROUTING -i br0 -s 192.168.1.0/24 -d 192.168.10.129/32 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.1.1
iptables -t nat -A POSTROUTING -o br0 -s 192.168.1.0/24 -d 192.168.1.1/32 -p tcp -m tcp --dport 8080 -j SNAT --to-source 192.168.1.254
于 2017-02-10T05:44:54.580 回答
2

今天我的番茄破烂路由器也遇到了同样的问题。在端口 85 上运行将接受来自内部局域网的连接,但不接受来自 WAN 的连接,所以我只是将端口 85 转发到 10.0.0.1(我的路由器的局域网地址)并且它工作。

于 2016-04-14T00:12:51.050 回答
0

尝试从 WAN 连接时遇到了同样的问题。端口转发到路由器的 IP 没有帮助。将此添加到Administration > Scripts > Firewall然后重新启动解决了我的问题:

iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
于 2017-08-20T19:58:23.410 回答