Express Proxy

0 views
Skip to first unread message

Catherin Bergan

unread,
Aug 4, 2024, 5:11:07 PM8/4/24
to carepowest
Toavoid same-domain AJAX issues, I want my node.js web server to forward all requests from URL /api/BLABLA to another server, for example other_domain.com:3000/BLABLA, and return to user the same thing that this remote server returned, transparently.

Note that request has been deprecated as of February 2020, so I'll leave the answer below for historical reasons, but please consider moving to an alternative listed in this issue, moving to the natively built-in Fetch API (as of Node 18), or using express-http-proxy.


I used the following setup to direct everything on /rest to my backend server (on port 8080), and all other requests to the frontend server (a webpack server on port 3001). It supports all HTTP-methods, doesn't lose any request meta-info and supports websockets (which I need for hot reloading)


In short, all nodejs http proxy packages work at the http protocol level, not tcp(socket) level. This is also true for express and all express middleware. None of them can do transparent proxy, nor NAT, which means keeping incoming traffic source IP in the packet sent to backend web server.


When setting to true , it is important to ensure that the last reverse proxy trusted is removing/overwriting all of the following HTTP headers: X-Forwarded-For , X-Forwarded-Host , and X-Forwarded-Proto otherwise it may be possible for the client to provide any value.


If you define a response modifier (userResDecorator, userResHeaderDecorator),or need to inspect the response before continuing (maybeSkipToNext), streamingis disabled, and the request and response are buffered.This can cause performance issues with large payloads.


Note: In express-http-proxy, the path is considered the portion ofthe url after the host, and including all query params. E.g. for the URL =123; the path is/search/path?q=123. Authors using this resolver must also handle the query parameter portion of the path.


Note:The other arguments (proxyRes, userReq, userRes) are passed by reference, soyou can currently exploit this to modify either response's headers, forinstance, but this is not a reliable interface. I expect to close thisexploit in a future release, while providing an additional hook for mutatingthe userRes before sending.


If your proxy response is gzipped, this program will automatically unzipit before passing to your function, then zip it back up before piping it to theuser response. There is currently no way to short-circuit this behavior.


This sets the body size limit (default: 1mb). If the body size is larger than the specified (or default) limit,a 413 Request Entity Too Large error will be returned. See bytes.js fora list of supported formats.


By default, express-http-proxy will pass any errors except ECONNRESET tonext, so that your application can handle or react to them, or just dropthrough to your default error handling. ECONNRESET errors are immediatelyreturned to the user for historical reasons.


My computer recently changed locations on the company internet. I have been using Direct Modeling Express for several years successfully but now I get a proxy request and warning when I start. It looks like I'll be thrown out after 72 hours?


For Modeling Express to automatically activate, it requires access to the internet. Please check if a proxy has to be specified, and enter your company's proxy server details so that the activation can proceed


I just downloaded the latest version of Direct Modeling Express, and tried to activate with no luck, it was also looking for a proxy server. I then tried to request activation key manually from the next screen, and got the following error message from Internet Explorer:


I too have had this issue. I was trying to evaluate Creo prior to purchasing a full license, when suddenly, it wont work anymore. I have checked and re-checked my machine. The fault does not lie there. I have tried a fresh install on a standalone machine and a new registration, same fault. When logging on to thier site this is successful but I get an security certificate error. I presume that this is the problem but have no way of proving it. I desperation I have tried on several occasions to get PTC's help but have restricted access to support. Published email addresses are bounced and sale will not respond. It seems that they just don't care and are totally unwilling to help in any way. I for one will treat this as the level of support that PTC will give their full product client too and am no longer bothering. Im going back to a company which offers support.


I think the issue at PTC is bigger than this. I have full support and have been having issues with my bookmarks not working. However, if I got to PTC and then to support I can get to the page. I think maybe some of the addresses have changed.


I don't know how anyone can refer to a recurring problem as solved. Again this month Modelling express d=fails to find the server and asks for reactivation, That fails and it asks for a 72 hour key. Press the button for key and get a code 4 times. Every time the key you entered is not valid.


When configuring the trust proxy setting, it is important to understand the exact setup of the reverse proxy. Since this setting will trust values provided in the request, it is important that the combination of the setting in Express matches how the reverse proxy operates.


When setting to true, it is important to ensure that the last reverse proxy trusted is removing/overwriting all of the following HTTP headers: X-Forwarded-For, X-Forwarded-Host, and X-Forwarded-Proto, otherwise it may be possible for the client to provide any value.


Use the address that is at most n number of hops away from the Express application. req.socket.remoteAddress is the first hop, and the rest are looked for in the X-Forwarded-For header from right to left. A value of 0 means that the first untrusted address would be req.socket.remoteAddress, i.e. there is no reverse proxy.


When using this setting, it is important to ensure there are not multiple, different-length paths to the Express application such that the client can be less than the configured number of hops away, otherwise it may be possible for the client to provide any value.


I am new to the PTC Creo Direct Modeling Express 6.0 setup, and downloaded this free single user CAD tool to get started with making 3D objects. I choose the 64-bit version, and installed on my Windows 8.1 machine. After installing, I want to start the program, and it asked me to activate for new users. After registering for an account with PTC, I then attempted to activate, and get the following:


I don't have any proxy settings in my browser, and am on a home network behind a NetGear wireless router. I do have access to the internet, and can't seem to determine why I am getting this message. Has anyone else seen this before? Any idea what I need to do to get PTC to see the internet?


Hi Ben, having the same issue. Express worked well since the initial download on 7/30/23 but now does not start. Instead a pop up dialogue prompting me for email and password to Activate comes up. After entering my e-address and password. and selecting 'Activate' I get a second dialogue saying: Connection failed. For Modeling Express to automatically activate it requires access to the internet. Please check if a proxy has to be specified and enter your company's proxy server details so that activation can proceed. I'm merely an individual with a laptop, there is no proxy server. My internet connection is fine and I have a basic PTC account with a valid password. Frustrating to be sure.


Unfortunately a lot of companies are still stuck with Windows servers. Nobody ever got fired for choosing Microsoft, right. As a developer this can be frustrating because choosing a server technology is usually limited to ASP.Net. I have experimented with hosting Node.js applications on a Windows server by using iisnode. But it is a pain to get up and running, setting the correct permissions is a time consuming chore. Microsoft has taken control of the development of the project but I get the feeling it's not very active any more. There are several Stackoverflow questions where people just give up configuring it.


So I wanted to go another route. What if we could use the Node.js web server and use IIS as a reverse proxy to route traffic to the Node.js web server? We could ditch iisnode and hopefully have a more reliable solution for hosting Node.js web applications.


To be able to run this, you need to install Node.js on your server. Once it's installed, you can run the test application by opening a command prompt and typing node app.js. If everything goes well you should now be able to access the test application via :3000 on your local server.


To configure IIS as reverse proxy you need to install the URL Rewrite extension and the Application Request Routing extension. The URL Rewrite extension allows you to define rules to enable URLs that are easier for users to remember and for search engines to find. The Application Request Routing extension enables scalibility features: load balancing, rule-based routing and more.


Once these extensions are installed, you can begin configuring IIS. Open the Internet Information Services (IIS) Manager by opening the run window and typing the inetmgr command. Select the site for which you want to set up the reverse proxy and open the URL Rewrite extension.


The last piece that's needed is a reliable way of running the Node.js application. Starting it via the command prompt and keeping the window open is not a durable solution. If someone logs on to the server and closes the window, the website goes down. pm2 is a Node.js process manager, it can be used to keep applications running. Installing pm2 is easy with npm:




Hi Peter, I came across this post because I want to deploy my node app in our windows server. Luckily this article looks great for my requirement. I'm just having a difficulty with the configurations of the bindings of my site. May I look on your site bindings? Should it be the same with the port I'm running on my Node App?

3a8082e126
Reply all
Reply to author
Forward
0 new messages