I have a website that is currently working (say, example.com). I have set up my virtual host file (example.conf) so that port 80 points to example.com:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
I have also set up ssl in a file called example-le-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
So far, so could. Now, I have installed a shiny server (which defaults to port 3838). I can access that by typing example.com:3838, but I want to access it by typing example.com/shiny. I read the instructions on how to set up a reverse proxy. In there, it says to replace 000-default.conf with:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
Of course, in my case, I assume I would do 3838 instead of 8080:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /shiny/ http://127.0.0.1:3838/
ProxyPassReverse /shiny http://127.0.0.1:3838/
</VirtualHost>
No luck. example.com/shiny can’t be found.
So, I change the ip address to my site’s url:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /shiny/ http://example.com:3838/
ProxyPassReverse /shiny http://example.com:3838/
</VirtualHost>
Still no luck, so I try my ip address:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /shiny/ http://[some ip address]:3838/
ProxyPassReverse /shiny http://[some ip address]:3838/
</VirtualHost>
Still no luck. So I think that maybe I need to change example.conf instead of 000-default.conf:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
** ProxyPreserveHost On
ProxyPass /shiny/ http://[some ip address]:3838/
ProxyPassReverse /shiny http://[some ip address]:3838/**
</VirtualHost>
```
Here I also tried the ip address, 127.0.0.1, and example.com. No luck.
What am I missing?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
I could suggest a few things:
- apachectl -M | grep proxy
If you already have the modules enabled, as you already mentioned, move the proxy rules to your 000-default.conf Vhost. That way you should be able to access the proxy rule via http and your domain name.
If you want to be able to access the proxy rules via https, you need to add the proxy rules to your SSL Vhost as well and in addition add the following rule:
SSLProxyEngine on
If this is still not working, make sure to check your Apache error log:
- sudo tail -100 /var/log/apache2/error.log
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.