Super User Asked by ZhaoGang on January 16, 2021
I have three micro services in my spring boot application. In front of them I have a Nignx server as an reverse proxy. Problem is that I have two network adapters(my pc is in two different LANs with different ip addresses , 192.168.43.17
and 192.168.184.170
seperately) and I want to config Nginx to start my application in both of LANs. Is it possible?
I tried add two servers block in the config file but failed, my nignx.conf
file:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name 192.168.184.170;
#return 307 $scheme://$host$request_uri;
#charset koi8-r;:
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
# proxy_pass http://192.168.43.123:3000/;
}
location ^~ /alertRecordCount/ { # ^~/api 琛ㄧず鍖归厤鍓嶇紑涓篴lertRecordCount鐨勮姹?
proxy_pass http://192.168.184.170:65533/alertRecordCount/; # 娉細proxy_pass鐨勭粨灏炬湁/锛?-> 鏁堟灉锛氫細鍦ㄨ姹傛椂灏?alertRecordCount/*鍚庨潰鐨勮矾寰勭洿鎺ユ嫾鎺ュ埌鍚庨潰
proxy_set_header Host $host;
}
location ^~ /users/signin {
proxy_pass http://192.168.184.170:65535/users/signin/;
proxy_set_header Host $host;
}
location ^~ /users/ {
proxy_pass http://192.168.184.170:65534/users/;
proxy_set_header Host $host;
}
location ^~ /alertRecords/ {
proxy_pass http://192.168.184.170:65533/alertRecords/;
proxy_set_header Host $host;
}
location ^~ /admin/ {
proxy_pass http://192.168.184.170:65533/admin/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name 192.168.43.17;
#return 307 $scheme://$host$request_uri;
#charset koi8-r;:
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
# proxy_pass http://192.168.43.123:3000/;
}
location ^~ /alertRecordCount/ { # ^~/api 琛ㄧず鍖归厤鍓嶇紑涓篴lertRecordCount鐨勮姹?
proxy_pass http://192.168.43.17:65533/alertRecordCount/; # 娉細proxy_pass鐨勭粨灏炬湁/锛?-> 鏁堟灉锛氫細鍦ㄨ姹傛椂灏?alertRecordCount/*鍚庨潰鐨勮矾寰勭洿鎺ユ嫾鎺ュ埌鍚庨潰
proxy_set_header Host $host;
}
location ^~ /users/signin {
proxy_pass http://192.168.43.17:65535/users/signin/;
proxy_set_header Host $host;
}
location ^~ /users/ {
proxy_pass http://192.168.43.17:65534/users/;
proxy_set_header Host $host;
}
location ^~ /alertRecords/ {
proxy_pass http://192.168.43.17:65533/alertRecords/;
proxy_set_header Host $host;
}
location ^~ /admin/ {
proxy_pass http://192.168.43.17:65533/admin/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
What I want is that other users with ip 192.168.184.*
can visit my application by visting 192.168.184.170:80
, while users with ip 192.168.43.*
can visit my application by visiting 192.168.43.17:80
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP