Use Apache to redirect any requests to node app and redirect http to https
I have a express app running together with a apache2 server. I am trying to setup a VirtualHost that proxys to my express app (Wich only serves HTTPS)
So I want to rewrite the http request to my https virtual host that then proxys to my node.js express app.
The express app runs on port 3500
But when I try to reach test.nw-system.de/api-docs
I get a 404 Error
I am running a Linux Ubuntu 18.04 Server, that is running as a VM under ESXi.
I have a Apache2 Server running together with my Node.js App.
I used to connect to it via: https://nw-system.de:3500, wich works without an Issue. But now I wanted to get rid of the port in the URL and use a subdomain instead. The express app only uses https (For encryption of username/password).
<VirtualHost *:80>
ServerName test.nw-system.de
ServerAdmin administrator@n-network.de
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName test.nw-system.de
ProxyPass /* http://localhost:3500/
ProxyPassReverse /* http://localhost:3500/
</VirtualHost>
When I try to reach http://test.nw-system.de/api-docs I expect to get redirected to https://test.nw-system.de/api-docs and then see the swagger api documentation wich is hosted by the express app.
Also I expect my api to be reachable under: https://test.nw-system.de/api/v1
Eg:
https://test.nw-system.de/api/v1/items
wich returns a json response
Sincerly, Jan
node.js apache express https
add a comment |
I have a express app running together with a apache2 server. I am trying to setup a VirtualHost that proxys to my express app (Wich only serves HTTPS)
So I want to rewrite the http request to my https virtual host that then proxys to my node.js express app.
The express app runs on port 3500
But when I try to reach test.nw-system.de/api-docs
I get a 404 Error
I am running a Linux Ubuntu 18.04 Server, that is running as a VM under ESXi.
I have a Apache2 Server running together with my Node.js App.
I used to connect to it via: https://nw-system.de:3500, wich works without an Issue. But now I wanted to get rid of the port in the URL and use a subdomain instead. The express app only uses https (For encryption of username/password).
<VirtualHost *:80>
ServerName test.nw-system.de
ServerAdmin administrator@n-network.de
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName test.nw-system.de
ProxyPass /* http://localhost:3500/
ProxyPassReverse /* http://localhost:3500/
</VirtualHost>
When I try to reach http://test.nw-system.de/api-docs I expect to get redirected to https://test.nw-system.de/api-docs and then see the swagger api documentation wich is hosted by the express app.
Also I expect my api to be reachable under: https://test.nw-system.de/api/v1
Eg:
https://test.nw-system.de/api/v1/items
wich returns a json response
Sincerly, Jan
node.js apache express https
You don't need*
in/*
– Dusan Bajic
Jan 2 at 21:43
Also, you should probably changehttp://localhost:3500/
tohttps://localhost:3500/
– Dusan Bajic
Jan 3 at 8:14
ty for you help. Now I just have issues with ESXi.
– Jan Krüger
Jan 3 at 14:54
add a comment |
I have a express app running together with a apache2 server. I am trying to setup a VirtualHost that proxys to my express app (Wich only serves HTTPS)
So I want to rewrite the http request to my https virtual host that then proxys to my node.js express app.
The express app runs on port 3500
But when I try to reach test.nw-system.de/api-docs
I get a 404 Error
I am running a Linux Ubuntu 18.04 Server, that is running as a VM under ESXi.
I have a Apache2 Server running together with my Node.js App.
I used to connect to it via: https://nw-system.de:3500, wich works without an Issue. But now I wanted to get rid of the port in the URL and use a subdomain instead. The express app only uses https (For encryption of username/password).
<VirtualHost *:80>
ServerName test.nw-system.de
ServerAdmin administrator@n-network.de
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName test.nw-system.de
ProxyPass /* http://localhost:3500/
ProxyPassReverse /* http://localhost:3500/
</VirtualHost>
When I try to reach http://test.nw-system.de/api-docs I expect to get redirected to https://test.nw-system.de/api-docs and then see the swagger api documentation wich is hosted by the express app.
Also I expect my api to be reachable under: https://test.nw-system.de/api/v1
Eg:
https://test.nw-system.de/api/v1/items
wich returns a json response
Sincerly, Jan
node.js apache express https
I have a express app running together with a apache2 server. I am trying to setup a VirtualHost that proxys to my express app (Wich only serves HTTPS)
So I want to rewrite the http request to my https virtual host that then proxys to my node.js express app.
The express app runs on port 3500
But when I try to reach test.nw-system.de/api-docs
I get a 404 Error
I am running a Linux Ubuntu 18.04 Server, that is running as a VM under ESXi.
I have a Apache2 Server running together with my Node.js App.
I used to connect to it via: https://nw-system.de:3500, wich works without an Issue. But now I wanted to get rid of the port in the URL and use a subdomain instead. The express app only uses https (For encryption of username/password).
<VirtualHost *:80>
ServerName test.nw-system.de
ServerAdmin administrator@n-network.de
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName test.nw-system.de
ProxyPass /* http://localhost:3500/
ProxyPassReverse /* http://localhost:3500/
</VirtualHost>
When I try to reach http://test.nw-system.de/api-docs I expect to get redirected to https://test.nw-system.de/api-docs and then see the swagger api documentation wich is hosted by the express app.
Also I expect my api to be reachable under: https://test.nw-system.de/api/v1
Eg:
https://test.nw-system.de/api/v1/items
wich returns a json response
Sincerly, Jan
node.js apache express https
node.js apache express https
asked Jan 2 at 20:48


Jan KrügerJan Krüger
236
236
You don't need*
in/*
– Dusan Bajic
Jan 2 at 21:43
Also, you should probably changehttp://localhost:3500/
tohttps://localhost:3500/
– Dusan Bajic
Jan 3 at 8:14
ty for you help. Now I just have issues with ESXi.
– Jan Krüger
Jan 3 at 14:54
add a comment |
You don't need*
in/*
– Dusan Bajic
Jan 2 at 21:43
Also, you should probably changehttp://localhost:3500/
tohttps://localhost:3500/
– Dusan Bajic
Jan 3 at 8:14
ty for you help. Now I just have issues with ESXi.
– Jan Krüger
Jan 3 at 14:54
You don't need
*
in /*
– Dusan Bajic
Jan 2 at 21:43
You don't need
*
in /*
– Dusan Bajic
Jan 2 at 21:43
Also, you should probably change
http://localhost:3500/
to https://localhost:3500/
– Dusan Bajic
Jan 3 at 8:14
Also, you should probably change
http://localhost:3500/
to https://localhost:3500/
– Dusan Bajic
Jan 3 at 8:14
ty for you help. Now I just have issues with ESXi.
– Jan Krüger
Jan 3 at 14:54
ty for you help. Now I just have issues with ESXi.
– Jan Krüger
Jan 3 at 14:54
add a comment |
0
active
oldest
votes
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012984%2fuse-apache-to-redirect-any-requests-to-node-app-and-redirect-http-to-https%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012984%2fuse-apache-to-redirect-any-requests-to-node-app-and-redirect-http-to-https%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You don't need
*
in/*
– Dusan Bajic
Jan 2 at 21:43
Also, you should probably change
http://localhost:3500/
tohttps://localhost:3500/
– Dusan Bajic
Jan 3 at 8:14
ty for you help. Now I just have issues with ESXi.
– Jan Krüger
Jan 3 at 14:54