To solve CORS issue, I need remove my server port and use apache to redirect to my tomcat with port.
example: http get url: localhost/app1/somerequest, my apache server will redirect to localhost:8080/app1/somerequest, so how can this redirect be work when i use nodejs?
If you want to proxy the request, use node-http-proxy.
If you want to redirect the request, see this
Related
I am running an NGINX server pointing to my proxy server which is running on Node. I am redirecting to app/ from node using express redirect. I am also passing a custom header using res.set("X-Custom-Header","XXX"); before the redirect. But the same header is not retrieved on app/ route on NGINX. Is there anything I am missing?
By default, nginx does not pass headers containing underscores.
Try:
underscores_in_headers on;
See this document for details.
I have a node app running on http://localhost:3000. I set up ssl/https with LetsEncrypt so all requests are 301 redirected to https. Im using Nginx as web server.
I'm trying to move my URL from resume.mydomain.com to mydomain.com/resume.
How do I forward requests to mydomain.com AND mydomain.com/resume to my node app?
If users go to mydomain.com AND resume.mydomain.com they should automatically be redirected to mydomain.com/resume.
How do I do this?
I have an apache webserver listening on port 80. With apache, a PHP/MySQL system based on Zend framework. And I also have a node server listening on port 3000.
When a client sends a request, always on port 80, it's therefore first handled by apache. I would like to apply the following rules before treating the request:
if content-type is "application/json" then
use apache web server
else if content-type is "application/zend" then
use apache web server
else
use node server
Here content-type is sent in the request headers. Content-type "application/zend" is a custom content-type to say that, for this type of particular request, we don't want to use node server (I need this for some reasons).
I've tried to modify httpd-vhosts.conf with
ProxyPreserveHost on
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
But that's of course not enough as not everything should be handled by the node server (listening on port 3000). Hence some rules should be added. But I'm unsure where/how. I also tried to change the .htaccess file, but not sure how either.
Any help would be great! Thanks!
This should work (in .conf file):
RewriteEngine on
RewriteCond %{HTTP:Content-type} !=application/json
RewriteCond %{HTTP:Content-type} !=application/zend
RewriteRule ^ http://%{HTTP_HOST}:3000%{REQUEST_URI} [P]
Keep in mind that this might carry a performance penalty, and if most of your requests end on node, we should perhaps search for better solution.
iHello everyone,
I'm in trouble with mod_rewrite in apache2
i'm trying to redirect all traffic incoming on localhost/music to localhost:8080, i've read a lot on apache documentation but i could not find a working example (http://httpd.apache.org/docs/2.0/misc/rewriteguide.html)
Can anyone tell me how to do this?
And no, i'm not trying to redirect traffic to tomcat (so i imagine i can't use mod_jk), i just want to see on alias /music my other app running on port 8080, it's a web stream music player called CherryMusic that is written in python and runs with html5.
I'm on debian server (precisely running raspbian on a raspberry pi)
Thanks in advance
in the following example, if your request to /music/(example.mp3) it will redirected with http status 302 to http://localhost:8080/example.mp3
RewriteEngine On
RewriteRule ^/music/(.*) http://localhost:8080/$1 [L,R=302]
In the above example the browser will be redirected to http://localhost:8080/example.mp3 (will work only for you cause it redirected to localhost)
if you are looking to proxy the request - the web server will connect to localhost:8080 , than you can do:
RewriteEngine On
RewriteRule ^/music/(.*) http://localhost:8080/$1 [L,P]
I'm using Passport-google to login users in example.com:3000. It works great. But if I put the Node.js server behind a proxy (IIS7; don't ask why, I had to), and access to my site in example.com (not in example.com:3000), I can't login with Passport-google. My RewriteRule in IIS:
Pattern (.*)
{HTTP_HOST} Matches myserver.com
{SERVER_PORT} Does not match 3000
Rewrite URL: http://127.0.0.1:3000/{R:1}
The error I got:
Cannot GET /accounts/o8/ud?
Also I have the same problem with Passport-twitter, and Passport-facebook.
I think I should set some other rule in IIS, or set some proxy settings in Passport.js, or OpenID, but haven't figured out yet. Any ideas?
The IIS proxy had a bad configuration. under Application Request Routing (ARR) / Server proxy settings Reverse rewrite host in response headers was switched on, so when passport sent a 302 with a location in header set to https://www.google.com/accounts/o8/... the IIS proxy replaced it to http://myserver.com/accounts/o8/... . which of course was an invalid link.