如何托管仅web.config的服务器? [英] How can I host a web.config-only server?

查看:134
本文介绍了如何托管仅web.config的服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅以下问题:在Azure Service Bus命名空间上启用CORS a>

See this question: Enable CORS on Azure Service Bus Namespace

真的,我想拥有一个仅前端的ReactJS应用程序,该应用程序与Azure API进行对话,并将结果的一部分呈现到屏幕上.然后从用户那里获取输入,并将其发送回Azure API.冲洗并重复. 不幸的是,CORS几乎排除了所有规则,并且您无法[1]覆盖ServiceBus命名空间的CORS规则.

Really I want to have a front-end only ReactJS app that talks to the Azure API, and renders bits of the result onto the screen. Then gets input from the users and sends that back to the Azure API. Rinse and repeat. Unfortunately CORS pretty much rules that out, and you can't[1] override the CORS rules for a ServiceBus Namespace.

因此,提出的解决方案是瘦代理服务器,代理Azure API以规避CORS.

So the proposed solution is a thin proxy server, proxying the Azure API, to circumvent CORS.

(非常欢迎您选择该问题的替代解决方案!)

(Alternative solutions to this question are HIGHLY welcome!)

[1]读:我目前看不到任何方式,我的Google搜索也看不到.

[1] read: I can't currently see any way to, and nor can my Google Searches.

另一个问题上的用户提出了相关的web.config文件,因此现在我想创建该代理服务器.我真的不希望该服务器做任何事情,其他,我希望它尽可能透明.

The user on that other question proposes the relevant web.config file, so now I want to create that proxy server. I don't really want that server doing anything else, I want it to be as transparent as possible.

设置该服务器的最简单方法是什么?

What is the simplest possible way to set up that server?

我有点希望我能够做类似的事情: 告诉Azure我想要一个Web服务器,并将该web.config文本粘贴/上传到Azure门户中?"

I'm kinda hoping that I would be able to do something like: "Tell Azure that I want a webserver, and paste/upload that web.config text into the Azure Portal"?

如果有意义的话,当前我的堆栈实际上只有npm和JS Create-React-App模板的堆栈.我在想我们也将网站托管在Azure中.

If it's relevant, currently my stack has literally nothing other than npm and the JS Create-React-App template's stack. I'm imagining we'll host the site in Azure too.

推荐答案

我可以使用它,而且很轻松-Azure可以JustDoThis.

I got this to work, and it was pretty painless - Azure can JustDoThis.

记录下我在这里为自己写的笔记,以备将来失去的流浪者:)

Documenting the notes I wrote for myself here, for any future lost wanderers :)

如链接的问题所述,Azure服务器没有(也不能)启用CORS,因此我们需要以某种方式绕开它.该方法是创建一个ReverseProxy服务器,该服务器接受请求,将其转发到Azure,接收响应,添加相关的CORS标头,然后将其返回给调用方.

As noted in the linked question, the Azure server doesn't (and can't) enable CORS, so we need to circumvent that in some manner. The approach is to create a ReverseProxy server, which accepts the request, forwards it to Azure, receives the response, adds the relevant CORS headers and and returns it to the caller.

从此Microsoft博客中进行以下步骤,除了跳过基本身份验证"步骤(第3步和第4步):

Followed steps, except skip the "Basic Authentication" step (Steps #3 & #4), from this Microsoft blog: https://blogs.msdn.microsoft.com/mihansen/2018/04/18/reverse-proxy-with-basic-authentication-in-azure-web-app/

  • 第1步:创建一个新的Azure Web应用
  • 第2步:添加applicationHost.xdt文件(在\Home\site中)
  • 第2a步:使用提供的模板设置.xdt文件的内容(我认为这实际上是web.config文件吗?
  • Step 1: Create a new Azure Web App
  • Step 2: Add applicationHost.xdt file (in \Home\site)
  • Step 2a: Set the contents of the .xdt file using provided template (I think it's literally a web.config file?
<?xml version="1.0"?>  
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  
<system.webServer>  
    <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />  
    </system.webServer>  
</configuration>

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆