當前位置:首頁 » 文件傳輸 » nginxip訪問
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

nginxip訪問

發布時間: 2022-03-01 18:58:45

1. nginx如何設置允許直接通過IP訪問網站

設置你監聽的埠,設置server_name為ip+埠

server {
listen 9000;
charset utf-8;
server_name xx.xx.xx.xx:9000;
......

}
重啟,然後就可以使用該IP訪問了

2. nginx 怎麼屏蔽通過ip訪問

我的伺服器也在阿里雲 按照你的說 接入阿里雲的waf對網站進行防護,但是如果直接通過IP地址訪問網站即可繞過阿里雲waf,於是希望禁止通過ip訪問網站
打開Nginx的配置文件nginx.conf
在server段里插入如下內容即可
if ($host != 'chaodiquan.com' ) {
return 403;
}
解釋一下,這段的意思是,如果訪問請求不是上面指定的域名,就返回403錯誤。

3. nginx怎麼配置IP和域名都能訪問

一個nginx伺服器只能有一個虛擬主機允許IP訪問
只要在server_name最後面添加一個default,就可以在其他nginx沒有定義的域名下,使用當前server解析(例如,其他server都沒有定義ip地址作為server_name則用IP訪問會被打到default主機上)

4. nginx 限制目錄訪問為403,允許其它訪問ip訪問怎麼變成404

nginx中針對目錄進行IP限制 ,這里以phpmyadmin目錄只能讓內網IP訪問,而外網不能訪問的配置方法。
nginx phpmyadmin 針對內網ip用戶開放、外網ip用戶關閉(在前面的配置中,location ~ ^/目錄/使用正則, 優先順序高於location /的配置,所以nginx無法對首頁進行解析)
代碼如下:
server {
listen 80;
server_name example.com;
access_log logs/access.log main;
location / {
root html;
index index.php index.html index.htm;
}
location ~ ^/phpmyadmin/ {
allow 192.168.1.0/24;
deny all;
location ~ .*.(php|php5)?$ {
root /var/mailapp/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
location ~ .*.(php|php5)?$ {
root /opt/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}

5. nginx 無法通過ip訪問網站怎麼解決

分析:拒絕用戶通過ip地址訪問網站。
方法:修改nginx.conf文件,添加如下內容
###################################################
upstream 訪問的ip
地址 {
server
分發的ip地址:80
max_fails=3 fail_timeout=30s;
server
分發的ip地址:80
max_fails=3 fail_timeout=30s;

}
server
{

listen 80;

#自定義錯誤文件

error_page 403 http://www.xxxx.com/error/403.html;
server_name
訪問的ip地址;
location
= / {
deny
all;

}
}

###################################################
結果:用戶使用以上定義的「訪問的ip地址」進行訪問時,將提示403.html中的內容。
同時error日誌中將記錄--2010/09/11
05:33:28 [error] 25107#0: *33370 access forbidden by rule, client:
124.115.0.106, server: 訪問的ip地址 request: "GET / HTTP/1.0",
hos
t: "訪問的ip地址"

6. nginx配置通過IP訪問返回靜態頁面

如果你以虛擬主機的方式在nginx上跑網站,就把默認的虛擬主機的主機名寫成ip地址 ,它的網站目錄下放錯誤信息提示頁面的html文件 。默認虛擬主機配置類似:

server {
listen 80;
server_name 192.168.1.12 default;
root D:\ServCode\www;
index index.html;
}

7. nginx 禁止ip訪問

因為這裡面只有一個server域,並且又設置了default標識,因此,此處可能是可以用ip進行訪問的。

如果想屏蔽掉ip訪問,只允許域名訪問的話,可以增加如下配置。

server {
#....
if ( $host ~* "d+.d+.d+.d+" ) {
return 400;
}
location / {
#....
}
}

這樣,當用ip訪問時,$host的值就為ip地址,如果$host否和ip的正則,就直接返回400給客戶端。

你不防線這樣試試。

8. 如何設置nginx可以讓ip可以直接訪問網站

設置你監聽的埠,設置server_name為ip+埠
server {
listen 9000;
charset utf-8;
server_name xx.xx.xx.xx:9000;
......

}
重啟,然後就可以使用該IP訪問了

9. nginx怎麼設置指定目錄ip訪問限制

nginx中針對目錄進行IP限制 ,這里以phpmyadmin目錄只能讓內網IP訪問,而外網不能訪問的配置方法。

nginxphpmyadmin針對內網ip用戶開放、外網ip用戶關閉(在前面的配置中,location ~ ^/目錄/使用正則, 優先順序高於location /的配置,所以nginx無法對首頁進行解析)

代碼如下:

server{
listen80;
server_nameexample.com;
access_loglogs/access.logmain;
location/{
roothtml;
indexindex.phpindex.htmlindex.htm;
}
location~^/phpmyadmin/{
allow192.168.1.0/24;
denyall;
location~.*.(php|php5)?${
root/var/mailapp/nginx/html;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
includefastcgi_params;
}
}
location~.*.(php|php5)?${
root/opt/nginx/html;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
includefastcgi_params;
}
}

10. 別人怎麼通過我的ip訪問我的nginx

直接在瀏覽器輸入你的IP就可以了

如果無法訪問先用內網IP測試看看,如果內網可以訪問,可能是路由器設定問題,
通訊埠轉發記得要開80埠給你的nginx的內網IP

如果內網就無法訪問,查看一下nginx的服務有沒有啟動,如果服務正常啟動,查看防火墻是否有開80埠訪問或者是防火墻是否有吧nginx服務阻擋掉