<!DOCTYPE html> <html> <head> <title>Welcome to Nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to Nginx!</h1> <p>If you see this page, the Nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://Nginx.org/">Nginx.org</a>.<br/> Commercial support is available at <a href="http://Nginx.com/">Nginx.com</a>.</p> <p><em>Thank you for using Nginx.</em></p> <script src="axios.min.js"></script> <script> function getServiceA(){ axios.get('/service_a/test') .then(function (response) { var x=document.getElementById("a") x.innerHTML=response.data; console.log(response); }) .catch(function (error) { console.log(error); }); } function getServiceB(){ axios.get('/service_b/test') .then(function (response) { var x=document.getElementById("b") x.innerHTML=response.data; console.log(response); }) .catch(function (error) { console.log(error); }); } </script> <button onclick='getServiceA()'>Get Service A</button><span id="a"></span> </br> </br> <button onclick='getServiceB()'>Get Service B</button><span id="b"></span> </body> </html>@H_502_0@下面Nginx的配置
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8484; server_name localhost; location / { root html; index index.html index.htm; } #------- location /service_a/ { proxy_pass http://localhost:5001/; } location /service_b/ { proxy_pass http://localhost:6001/; } #------- error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }@H_502_0@其实的A服务,B服务相似
namespace NginxTest1.Controllers { [ApiController] [Route("[controller]")] public class TestController : ControllerBase { private readonly ILogger<TestController> _logger; public TestController(ILogger<TestController> logger) { _logger = logger; } [HttpGet] public string Get() { var str = "ServiceA:5001_" + DateTime.Now; _logger.Log@R_503_4045@ion(str); return str; } } }@H_502_0@运给的结果 @H_502_0@
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。