简体   繁体   English

重定向/发布到localhost而不是外部域

[英]Redirect/Post to localhost instead of external domain

I have 2 apps, both live, one of them lets say webapp1 uses webapp2 to authenticate user, during that process it posts to a url from webapp2 passing some query parameters as well. 我有2个应用程序,都是实时的,其中一个让我们说webapp1使用webapp2来验证用户,在这个过程中它会从webapp2发布到一个url传递一些查询参数。 recently there are some issues started appearing which can only be replicated in production as the webapp1 only has production instance, so to replicate this issue in local, i need to do something in my dev machine so that when i open webapp1 prod url in my machine, and it redirects to webapp2 prod url to login, it shall actually redirect to same replica of webapp2 in my localhost, IIS 7.5 hosted. 最近有一些问题开始出现,只能在生产中复制,因为webapp1只有生产实例,所以要在本地复制这个问题,我需要在我的开发机器上做一些事情,这样当我在我的机器中打开webapp1 prod url时,它重定向到webapp2 prod url登录,它实际上应该重定向到我的localhost,IIS 7.5托管的webapp2的同一个副本。

Details: both are web applications, their domain setup like this in prod: 详细信息:两者都是Web应用程序,它们的域设置如下:

webapp1: https://webapp1.example.com/abc/xyz webapp1: https ://webapp1.example.com/abc/xyz

webapp2 url: https://www.example.com/webapp2/login.aspx?abc=sometext&State=somestatetext webapp2网址: https ://www.example.com/webapp2/login.aspx abc = sometext State = somestatetext

Now when i open webapp1's production url in my local, and it does post to webapp2's prod url, posting some data to it along with some query parameters, then i want that to rather redirect posting same data and passing same params to local instance of webapp2 running in my local machine, for example to this: https://localhost/webapp2/login.aspx?abc=sometext&State=somestatetext 现在,当我在我的本地打开webapp1的生产URL时,它会发布到webapp2的prod url,向它发布一些数据以及一些查询参数,然后我想要重新定向发布相同的数据并将相同的参数传递给webapp2的本地实例在我的本地机器上运行,例如: https://localhost/webapp2/login.aspx?abc = sometext&State = somestatetext

Is there any way to achieve this without changing anything in webapp1 or 2 in production? 有没有办法实现这一点而不改变生产中的webapp1或2中的任何内容?

I feel it doesn't matter much but still webapp2 is aps.net web form app and my local machine is windows 7. 我觉得它没关系,但仍然webapp2是aps.net网络表单应用程序,我的本地机器是Windows 7。

Tried few options but not sure they are right approach: 尝试了几个选项但不确定它们是否正确:

  1. modify host file 修改主机文件

modify host file to point example.com to localhost: but as both webapp1 and 2 are in same domain in prod, so i can't access prod url of webapp1 in my local machine, as that tries to open from my local, which i don't want to happen as i need webapp1 prod url to start request to my local. 修改主机文件以将example.com指向localhost:但由于webapp1和2都在prod中的同一个域中,所以我无法在本地计算机中访问webapp1的prod url,因为它试图从我的本地打开,我不想发生因为我需要webapp1 prod url来启动我当地的请求。

  1. trying this chrome extension: 尝试这个chrome扩展:

https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg?hl=en https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg?hl=en

it looks promising but not sure if that does same what i am expecting/need, means can it mimic exact same post to localhost and pass all params as is? 它看起来很有前景,但不确定是否与我期望/需要的相同,意味着它可以模仿完全相同的帖子到localhost并按原样传递所有参数吗? anyone has any prior experience with this? 有没有人有这方面的经验?

Just to share if someone else ends up with same/similar needs. 只是为了分享,如果其他人最终有相同/类似的需求。

I ended up using this extension, its pretty useful and helps to redirect request to one domain to another paired domain. 我最终使用此扩展,它非常有用,并有助于将请求重定向到一个域到另一个配对域。 Beauty is you need not do anything in hosts file or anywhere else to get it working. 美丽是你不需要在主机文件或其他任何地方做任何事情来使它工作。

With it, i could map my prod/stage/test to my local dev and have them all saved for future usage and per need i can decide which pair i want browser to use for given testing. 有了它,我可以将我的prod / stage / test映射到我的本地dev并将它们全部保存以备将来使用,并且根据需要我可以决定我希望浏览器使用哪一对进行给定的测试。

https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM