nginx分布式域名访问反向代理nginx.conf文件配置

痛定思痛。 2022-05-03 11:26 338阅读 0赞

配置hosts文件:

192.168.25.100 manager.haomai.com

192.168.25.100 www.haomai.com

192.168.25.100 search.haomai.com

192.168.25.100 item.haomai.com

192.168.25.100 sso.haomai.com

192.168.25.100 cart.haomai.com

192.168.25.100 order.haomai.com

nginx.conf文件配置:

  1. #user nobody;
  2. worker_processes 1;
  3. #error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;
  6. #pid logs/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. # '$status $body_bytes_sent "$http_referer" '
  15. # '"$http_user_agent" "$http_x_forwarded_for"';
  16. #access_log logs/access.log main;
  17. sendfile on;
  18. #tcp_nopush on;
  19. #keepalive_timeout 0;
  20. keepalive_timeout 65;
  21. #gzip on;
  22. upstream manager.haomai.com {
  23. server 192.168.25.137:8080;
  24. }
  25. upstream www.haomai.com {
  26. server 192.168.25.137:8081;
  27. }
  28. upstream search.haomai.com {
  29. server 192.168.25.137:8082;
  30. }
  31. upstream item.haomai.com {
  32. server 192.168.25.138:8080;
  33. }
  34. upstream sso.haomai.com {
  35. server 192.168.25.138:8081;
  36. }
  37. upstream cart.haomai.com {
  38. server 192.168.25.139:8080;
  39. }
  40. upstream order.haomai.com {
  41. server 192.168.25.139:8081;
  42. }
  43. server {
  44. listen 80;
  45. server_name manager.haomai.com;
  46. #charset koi8-r;
  47. #access_log logs/host.access.log main;
  48. location / {
  49. proxy_pass http://manager.haomai.com;
  50. index index.html index.htm;
  51. }
  52. }
  53. server {
  54. listen 80;
  55. server_name www.haomai.com;
  56. #charset koi8-r;
  57. #access_log logs/host.access.log main;
  58. location / {
  59. proxy_pass http://www.haomai.com;
  60. index index.html index.htm;
  61. }
  62. }
  63. server {
  64. listen 80;
  65. server_name search.haomai.com;
  66. #charset koi8-r;
  67. #access_log logs/host.access.log main;
  68. location / {
  69. proxy_pass http://search.haomai.com;
  70. index index.html index.htm;
  71. }
  72. }
  73. server {
  74. listen 80;
  75. server_name item.haomai.com;
  76. #charset koi8-r;
  77. #access_log logs/host.access.log main;
  78. location / {
  79. proxy_pass http://item.haomai.com;
  80. index index.html index.htm;
  81. }
  82. }
  83. server {
  84. listen 80;
  85. server_name sso.haomai.com;
  86. #charset koi8-r;
  87. #access_log logs/host.access.log main;
  88. location / {
  89. proxy_pass http://sso.haomai.com;
  90. index index.html index.htm;
  91. }
  92. }
  93. server {
  94. listen 80;
  95. server_name cart.haomai.com;
  96. #charset koi8-r;
  97. #access_log logs/host.access.log main;
  98. location / {
  99. proxy_pass http://cart.haomai.com;
  100. index index.html index.htm;
  101. }
  102. }
  103. server {
  104. listen 80;
  105. server_name order.haomai.com;
  106. #charset koi8-r;
  107. #access_log logs/host.access.log main;
  108. location / {
  109. proxy_pass http://order.haomai.com;
  110. index index.html index.htm;
  111. }
  112. }
  113. }

发表评论

表情:
评论列表 (有 0 条评论,338人围观)

还没有评论,来说两句吧...

相关阅读