当前位置:   article > 正文

nginx统一入口 多服务出口

nginx 多出口ip
  1. nginx配置多ip和端口统一调用入口
  2. log_format中$upstream_addr 标识打印转发的url地址
  3. 配置upstream和location
  4. http {
  5. include mime.types;
  6. default_type application/octet-stream;
  7. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  8. '$status $body_bytes_sent "$http_referer" '
  9. '"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr" ';
  10. access_log logs/access.log main;
  11. sendfile on;
  12. #tcp_nopush on;
  13. #keepalive_timeout 0;
  14. keepalive_timeout 65;
  15. #gzip on;
  16. upstream osg-p0001{
  17. server 192.168.9.92:8300;
  18. }
  19. upstream osg-p0002{
  20. server 192.168.9.57:8301;
  21. }
  22. upstream osg-p0003{
  23. server 192.168.0.0:8301;
  24. }
  25. upstream osg-p0004{
  26. server 192.168.9.92:8303;
  27. }
  28. upstream osg-p0005{
  29. server 192.168.0.0:8301;
  30. }
  31. server {
  32. listen 8080;
  33. server_name localhost;
  34. #charset koi8-r;
  35. #access_log logs/host.access.log main;
  36. location /osg-p0001/{
  37. proxy_pass http://osg-p0001;
  38. }
  39. location /osg-p0002/{
  40. proxy_pass http://osg-p0002;
  41. }
  42. location /osg-p0003/{
  43. proxy_pass http://osg-p0003;
  44. }
  45. location /osg-p0004/{
  46. proxy_pass http://osg-p0004;
  47. }
  48. location /osg-p0005/{
  49. proxy_pass http://osg-p0005;
  50. }
  51. #location / {
  52. # root html;
  53. # index index.html index.htm;
  54. # }
  55. #error_page 404 /404.html;
  56. # redirect server error pages to the static page /50x.html
  57. #
  58. error_page 500 502 503 504 /50x.html;
  59. location = /50x.html {
  60. root html;
  61. }
  62. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  63. #
  64. #location ~ \.php$ {
  65. # proxy_pass http://127.0.0.1;
  66. #}
  67. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  68. #
  69. #location ~ \.php$ {
  70. # root html;
  71. # fastcgi_pass 127.0.0.1:9000;
  72. # fastcgi_index index.php;
  73. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  74. # include fastcgi_params;
  75. #}
  76. # deny access to .htaccess files, if Apache's document root
  77. # concurs with nginx's one
  78. #
  79. #location ~ /\.ht {
  80. # deny all;
  81. #}
  82. }
  83. # another virtual host using mix of IP-, name-, and port-based configuration
  84. #
  85. #server {
  86. # listen 8000;
  87. # listen somename:8080;
  88. # server_name somename alias another.alias;
  89. # location / {
  90. # root html;
  91. # index index.html index.htm;
  92. # }
  93. #}
  94. # HTTPS server
  95. #
  96. #server {
  97. # listen 443 ssl;
  98. # server_name localhost;
  99. # ssl_certificate cert.pem;
  100. # ssl_certificate_key cert.key;
  101. # ssl_session_cache shared:SSL:1m;
  102. # ssl_session_timeout 5m;
  103. # ssl_ciphers HIGH:!aNULL:!MD5;
  104. # ssl_prefer_server_ciphers on;
  105. # location / {
  106. # root html;
  107. # index index.html index.htm;
  108. # }
  109. #}
  110. include servers/*;

}

转载于:https://my.oschina.net/u/435726/blog/2208617

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/207305
推荐阅读
相关标签
  

闽ICP备14008679号