I'm trying to setup my app on HTTPS on a web server. I have a valid certificate that is installed on my InMotion host using AutoSSL. I have the node app running on my Centos server on port 3000 and my apache SSL server running on port 443. To route requests made to my website, I am attempting to create a reverse-proxy. I made a file called default-site.conf which is stored in /etc/http.d/conf.d and has the following contents:
<VirtualHost _default_:443>
SSLProxyEngine on
ServerName example.com
ServerAlias www.example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
ServerAdmin info#example.com
DocumentRoot /home/USER/my-app/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /home/USER/ssl/certs/certificate.crt
SSLCertificateKeyFile /home/USER/ssl/keys/certificate.key
ProxyPass / https://example.com:3000/
ProxyPassReverse / https://example.com:3000 /
<Directory "/home/USER/my-app/public">
AllowOverride All
</Directory>
</VirtualHost>
I will emphasize that the app is accessible at http://example.com:3000 (insecure) but when I attempt to go to https://example.com (secure) I get my blank index.html with a 404 error:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (index.js, line 0)
I managed to fix this issue by completely simplifying my config to the following two lines:
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
This may not be the most flexible approach but it reroutes the traffic the way I need it to be routed, so for my purposes, it works.
Related
My system is hosted by Amazon LighSail.
My application is running with Nodejs on the port 3000.
I installed my HTTPS certificate for my domain name with Let's Encrypt.
Now I want to reach my nodejs application directly to my sub-domain.domain.com.
When I go to my domain name (sub-domain.domain.com), I'm directed to the bitnami home page.
So I have:
https://sub-domain.domain.com --> bitnami home page
IP-ADDRESS:3000 --> my nodejs application
I add a proxy to redirect all HTTP request to my port 3000 but with no sucess.
My proxy added in /etc/apache2/sites-enabled/000-default.conf :
< VirtualHost *:80 >
ServerAdmin webmaster#localhost
ServerName www.sub-domain.domain.com
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
< / VirtualHost >
Someone has an idea to solve my problem or any clue?
With SSL Cert the config should look more like this:
<VirtualHost *:80>
ServerName yoursite.com
ServerAlias *yoursite.com
ServerAdmin example#yoursite.com
DocumentRoot /var/www/yourSite
LogLevel debug
SSLEngine on
SSLCertificateFile /path/to/lets/encrypt/cert
SSLCertificateKeyFile /path/to/lets/encrypt/key
SSLProxyEngine on
ProxyPass "/" "http://127.0.0.1:3000/"
ProxyPassReverse "/" "http://127.0.0.1:3000/"
ErrorLog ${APACHE_LOG_DIR}/yourSite_error_https.log
CustomLog ${APACHE_LOG_DIR}/yourSite_access_https.log combined
</VirtualHost>
Solved ! I had to add my proxy in this file: /opt/bitnami/apache2/conf/bitnami/bitnami.conf
I’ve the done below following steps to enable Apache server status in httpd.config configuration.
LoadModule status_module modules/mod_status.so
Virtual host:
<VirtualHost *:20443>
ServerName dev-server.com
<Location /server-status>
SetHandler server-status
Order allow,deny
Deny from all
Allow from all
</Location>
</VirtualHost>
ExtendedStatus On
I'm getting error accessing server status screen.
I have this on my Apache 2 file "example.com.conf". I am only able to access it only by IP, but when I try to access it for the server name always I got the following error:
Network Error (dns_server_failure)
<VirtualHost *:80>
ServerAdmin myemail
DocumentRoot /var/www/html/example.com
ServerName example.com
ServerAlias www.example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I'm running Ubuntu 14.04.03 (X64)
I try to access this on a machine with Windows 8.1.
I have a VPS using apache on port 80, but want to use node.js for a subdomain, without the port node will be using appear in the address bar.
Yes it is possible
In your apache virtual host file configure with the following:
<VirtualHost *:80>
ServerName subdomain.myapp.com
ProxyRequests off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ProxyPreserveHost on
</VirtualHost>
You should have
NameVirtualHost *:80
I have a ubuntu server running a few apache websites. I want to run a nodejs app on the same server. I have the app running on the server now out of port 3000 (www.example.com:3000) no problems there.
I now want to direct a new domain to the nodejs app with my existing apache setup. Below is an example of the config i'm running however it's pointing to a folder. What i require is the config that points to the app's port. And any extras that I maybe missing.
<VirtualHost *:80>
ServerAdmin spam#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /srv/www/example.com/public_html/
ErrorLog /srv/www/example.com/logs/error.log
CustomLog /srv/www/example.com/logs/access.log combined
</VirtualHost>
First of all, you should to install mod_proxy and mod_proxy_http.
Then you can use something like the following configuration:
<VirtualHost *:80>
ServerAdmin spam#example.com
ServerName example.com
ServerAlias www.example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>