I have one machine on which I am running an application and can be accessed through an URL: http://myapp0:port and on another machine (connected to another internet provider) I have one web page which is accessing the first url: http:myapp0:port. Is it possible to change this URL http://myapp0:port into the http://myapp1.
on httpd.conf I have the following:
<VirtualHost *:80>
ServerAdmin myapp1.ro
DocumentRoot "${SRVROOT}/htdocs"
ServerName myapp1.ro
ErrorLog "${SRVROOT}/logs/myapp1.ro.com-error.log"
CustomLog "${SRVROOT}/logs/myapp1.ro-access.log" common
RewriteEngine On
RewriteRule "http://myapp0:9999" "http://myapp1.ro"
Thank you
Please use the following configuration within your VHost, this will redirect all the request to this specific Vhost to http://myapp1.ro.
Redirect / http://myapp1.ro
Related
I have a website where I'm wanting 1 file (version.txt) to be accessible via regular HTTP, but I want everything else to redirect to https. To do this, I added the "RedirectMatch" line below in my /etc/httpd/conf.d/somewhere.com.conf file (running centos7). Before I wanted to serve this file via HTTP, the line was a "Redirect permanent" type line. When I first made this change, I did some tests and it appeared to work; I was definitely able to access version.txt with plain HTTP, and I thought other accesses were being redirected to https. However, I just navigated to the website today and noticed it was all coming over HTTP. I have very little knowledge with websites, so I'm guessing that my testing for the redirect was faulty due to browser caching or something that tricked me into thinking it was working.
The question: in my conf.d file below, why doesn't the website redirect everything except version.txt to https? How can I change it so that it allows HTTP access of version.txt, but redirects everything else to HTTPS?
<VirtualHost *:80>
ServerName somewhere.com
ServerAdmin somebody#somewhere.com
DocumentRoot /var/www/somewhere.com
ErrorLog /etc/httpd/logs/error_log_somewhere
CustomLog /etc/httpd/logs/access_log_somewhere combined
RedirectMatch permanent "^(/*version.txt/.*)" https://somewhere.com$1
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/somewhere.com_ssl_certificate.cer
SSLCertificateKeyFile /etc/pki/tls/private/_.somewhere.com_private_key.key
SSLCertificateChainFile /etc/pki/tls/certs/_.somewhere.com_ssl_certificate_INTERMEDIATE.cer
ServerName somewhere.com
ServerAlias www.somewhere.com
ServerAdmin somebody#somewhere.com
DocumentRoot /var/www/somewhere.com
ErrorLog /etc/httpd/logs/error_log_somewheres
CustomLog /etc/httpd/logs/access_log_somewheres combined
</VirtualHost>
ServerSignature Off
ServerTokens Prod
Header always append X-Frame-Options SAMEORIGIN
edit: bonus if you have any ideas on what fooled me into thinking it was working at first
You can use the below redirection inside <VirtualHost *:80>.
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
Above rule will redirect any context to https with context.
Trying to get multiple domains (potentially dozens) to use the same document root as I want laravel to take care of all the routing.
Sites will be custom domain names ie. johnwilson.com, davidsmith.com, lisabrown.com and laravel will display a templated page. I do not want the URL rewritten in the address bar to the user.
I can't get apache2 to respect my virtual host configuration though, especially using SSL.
The configuration is a LAMP stack on Ubuntu. I have two other runrelated sites already running successfully on this server, using two seperate document roots. These are proxied through cloudfare.
These "templated" pages I'm just going to use lets encrypt for though.
I've tried:
2 seperate virtual hosts.
<VirtualHost *:443>
ServerName johnsmith.com.au
DocumentRoot /var/www/microsites/public
# letsencrypt certificate details here
</VirtualHost>
<VirtualHost *:443>
ServerName lisabrown.com.au
DocumentRoot /var/www/microsites/public
# letsencrypt certificate details here
</VirtualHost>
In this case johnsmith.com.au works, but lisabrown.com.au just redirects to johnsmith.com.au. completely rewriting the url in the address bar.
I've tried using ServerAlias aswell but this leads me to various errors, 404, SSL_INSECURE.
What's the correct way to do this? TIA
Using the following conf files (one per domain) I got it to work as expected. (and deleting the letsencrypt auto generated domain-le-ssl.conf file)
<VirtualHost *:80>
ServerName domain.com.au
ServerAlias www.domain.com.au
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.domain.com.au [OR]
RewriteCond %{SERVER_NAME} =domain.com.au
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName domain.com.au
ServerAdmin admin#domain.com.au
DocumentRoot /var/www/microsites/public
ErrorLog ${APACHE_LOG_DIR}/microsites/domain.error.log
CustomLog ${APACHE_LOG_DIR}/microsites/domain.access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/domain.com.au/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com.au/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
How can I force HTTPS on my website? I tried the solution from this answer, but for some reason I get redirected to the parent directory when I visit the index page by clicking on a link (it worked fine before adding those lines of code in .htaccess). Also, when I try to visit my website using HTTP, it lets me do it. What am I missing?
With Apache, you have several alternatives - including .htaccess.
Look here:
https://wiki.apache.org/httpd/RedirectSSL
Per the documentation, your best bet is to use a Redirect directive inside the non-secureVirtualHost:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.example.com
DocumentRoot /usr/local/apache2/htdocs
Redirect permanent /secure https://mysite.example.com/secure
</VirtualHost>
<VirtualHost _default_:443>
ServerName mysite.example.com
DocumentRoot /usr/local/apache2/htdocs
SSLEngine On
# etc...
</VirtualHost>
Here is an .htaccess example, from the same link:
Redirect permanent /login https://mysite.example.com/login
Finally, look here for additional troubleshooting tips (for example, forgetting 'NameVirtualHost *:443' to enable Named virtual hosting for port 443):
Why might Apache ignore a virtual host with a ServerName matching the requested URL?
I have a Plone site called example.com located at /var/www/Plone (I think). I have the following settings for the site located in sites-available for vhosts (excerpt):
<VirtualHost 10.0.1.4:8082>
ServerAdmin webmaster#localhost
ServerName wiedhas.noip.me
DocumentRoot /var/www/Plone
When I try to reach my site wiedhas.noip.me, apache loads the Plone directory tree and not my Plone site. I can browse through the file system of /var/www/Plone but it is not loading the site. I must not have set the documentroot to the correct directory of my site? Any help much appreciated.
This an excellent docu about running plone behind apache and more.
http://docs.plone.org/manage/deploying/front-end/apache.html
A simple example with ssl, how a vhost could look like:
<VirtualHost $IP:80>
ServerName my.domain.com
Redirect / https://my.domain.com
</VirtualHost>
<VirtualHost $IP:443>
ServerName my.domain.com
ErrorLog logs/my.domain.com-http-error.log
CustomLog logs/my.domain.com-http-access.log combined
Include vhosts.d/....ssl.inc
RewriteEngine On
RewriteRule ^/(.*) http://127.0.0.1:$PORT_OF_PLONE/VirtualHostBase/https/%{SERVER_NAME}:%{SERVER_PORT}/zodb/path/top/plone/VirtualHostRoot/$1 [P,L]
</VirtualHost>
The most important part is the rewrite rule:
RewriteRule ^/(.*) http://127.0.0.1:$PORT_OF_PLONE/VirtualHostBase/https/%{SERVER_NAME}:%{SERVER_PORT}/zodb/path/top/plone/VirtualHostRoot/$1 [P,L]
$PORT_OF_PLONE = Port of your running plone instance
/zodb/path/top/plone = That's where you added the plone site in zope.
Took me a while to get mine going so maybe this helps:
My vhosts looks like this (where my plone site is called 'mywebsite'):
#---------------------------------
# www.mywebsite.com
#---------------------------------
<VirtualHost *:80>
ServerName www.mywebsite.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/(.*)$ http://127.0.0.1:8081/VirtualHostBase/http/%{SERVER_NAME}:80/mywebsite/VirtualHostRoot/$1 [L,P]
</IfModule>
</VirtualHost>
Hope that helps :)
As you see in the first and correct answer you do not need DocumentRoot. DocumentRoot points to a directory with files to render by Apache. But Plone brings it's own server, the Zope application server, which runs on a different port than Apache. The RewriteRule redirects the incoming request to the application server and modifies the response in a way that the redirection is hidden for the client.
I am not skilled in this field and hence want a solution to this.
I have a domain (www.domain.com) hosted on server 1. I want m.domain.com which is on server 1 to show the contents of the folder(folder name:m.domain.com) which is on server 2. Both are on shared hosting servers.
You haven;t given enough information for a full solution, so I'll need to assume a few items.
First, let's assume server 2 is called x.domain.com. On m.domain.com you will need to setup your apache config as follows:
<VirtualHost *:80>
ServerName m.example.com
Redirect / http://x.example.com/
</VirtualHost>
It will redirect all requests from m.example.com to x.example.com.
On x.example.com you will need to set the folder m.domain.com as your root:
<VirtualHost *:80>
ServerAdmin foo#bar.org
ServerName x.domain.com
DocumentRoot /path/to/m.domain.com
Options -Indexes
</VirtualHost>