I installed and config mod_ssl in httpd service on CentOS like this link:
https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-centos-6
And this is my config in httpd.conf:
<VirtualHost x.x.x.x:80>
<Directory /var/www/html/source>
AllowOverride All
</Directory>
DocumentRoot /var/www/html/source
ServerName sub.domain.com.vn
</VirtualHost>
<VirtualHost x.x.x.x:443>
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key
DocumentRoot /var/www/html/source
ServerName sub.domain.com.vn
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
</VirtualHost>
x.x.x.x is my server IP
And the problem is I can access http:// sub.domain.com.vn but can not access to https:// sub.domain.com.vn. I can telnet to port 443 normally. Port 443 and HTTPS protocol is ready.
netstat -tap | grep https
tcp 0 0 *:https : LISTEN 1
netstat -tlnp | grep 443
tcp 0 0 :::443 :::* LISTEN 1
But when I access to https:// sub.domain.com.vn it print out a error "This webpage is not available ERR_CONNECTION_CLOSED". Can anybody give me a help please ? Forgive me if my english not good enough. Port 443 on my server is opened, I checked.
Related
I have vps server in Ubuntu 18.04. my backend project is Laravel so frontend is Nuxt. I want deploy my laravel project as subdomain in 80 port. example : api.domain.com. Frontend project deploy in 3000 port as main domain. example domain.com. How I configure my apache for subdomain and how redirect main domain 3000 port?
You can configure your Apache to proxy port 80 -> 3000.
<VirtualHost *:80>
ServerName api.domain.com
DocumentRoot "/your/laravel/application/path/public"
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName domain.com
ServerAlias domain.com
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
Once you're done with configuring Apache, you'll have to enable the required Apache modules and restart.
sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart
[Derived from this answer.]
As for your Laravel application, I'm going to assume you've installed PHP and loaded the Apache PHP module.
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'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.
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>