![](/img/trans.png)
[英]I am trying to scrape a website with Node.js, but I got blocked from the website. How can I solve this?
[英]I am trying to host a website using nginx reverse proxy method, i am running two Node.js applications
我的第一個應用程序在8080上運行,第二個應用程序在8081上運行,代碼如下:
server {
listen 80;
server_name greatwallprojects.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /pingtest {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
嘗試打開第二個位置頁面后,基本上可以看到一個空白頁面,該首頁工作正常,但是http://greatwallprojects.com/pingtest加載了一個空白頁面。 如果反向代理方法有問題,我應該嘗試其他方法嗎? 誰能指出這個問題?
我認為應該可以
upstream application_1 {
server 127.0.0.1:8080;
}
upstream application_2 {
server 127.0.0.1:8081;
}
server {
listen 80;
server_name greatwallprojects.com;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_pass http://application_1;
}
location ~* ^\/pingtest$ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_pass http://application_2;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.