这可能不仅仅是一个web2py问题,但我尝试了一些建议的方法(https://webmasters.stackexchange.com/questions/59624/allowing-access-to-an-apache-virtual-host-from-the-local-network-only)来配置/ etc / apache2 / sites中的default.conf文件 - 通过向VirtualHost添加一个新目录,我可以不知道我的配置文件是错误的还是我在错误的文件中执行它或者web2py有一个更简单的方法来处理它。 问题是,即使使用此代码,仍然可以从非本地IP访问app2。
<VirtualHost *:8000>
WSGIProcessGroup web2py
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /home/www-data/web2py/applications/app1>
AllowOverride None
Require all denied
<Files wsgihandler.py>
Require all granted
</Files>
</Directory>
<Directory /home/www-data/web2py/applications/app2>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
Allow from localhost
Allow from 192.168
Allow from 10
Satisfy Any
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2
<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 hour"
Require all granted
</Directory>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>