My first application is running on 8080, the second application is running on 8081, The code is as follows:
我的第一个应用程序运行在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;
}
}
I basically see a blank page once i try to open the second location page, the homepage works fine, but http://greatwallprojects.com/pingtest loads a blank page. If the reverse proxy method has issues should i try other methods?. Can anyone point out the issue?
一旦我尝试打开第二个位置页面,我基本上看到一个空白页面,主页工作正常,但http://greatwallprojects.com/pingtest加载一个空白页面。如果反向代理方法有问题我应该尝试其他方法吗?有谁可以指出这个问题?
1 个解决方案
#1
I think that should work
我认为这应该有效
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;
}
}
#1
I think that should work
我认为这应该有效
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;
}
}