I have a wordpress site running on wordpress.myorg.com. For authentication I have to redirect it my internal server running CAS server.
Internal Server does not have DNS name. So, I’m using local DNS with IP address in HOST file to redirect to CAS server. All the things working correctly such a way.
Now I wanted to add ProxyPass rules, so that the User only sees wordpress.myorg.com all the time.
After adding ProxyPass rules, when I hit wordpress.myorg.com/wp-login.php it returns page with 500 internal error rather then showing CAS login screen.
Here is the Virtual Host entry I have done in Apache web server for Wordpress Site
<VirtualHost *:80>
ServerAdmin your_email_address
ServerName wordpress.myorg.com
ServerAlias wordpress.myorg.com
DocumentRoot /var/www/html/wordpress
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/wordpress>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} !=on
RewriteRule ^/?CAS/(.*) https://wordpress.myorg.com/CAS/$1 [R,NE,L]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin your_email_address
ServerName wordpress.myorg.com
ServerAlias wordpress.myorg.com
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/myorg.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/myorg.com.key
ProxyRequests On
ProxyVia On
ProxyPass /CAS/ ajp://cas.myorg.com:8009/CAS/
ProxyPassReverse /CAS/ ajp://cas.myorg.com:8009/CAS/
</VirtualHost>
Any help on this would be appreciable.
Thanks.
Got the issue. I forgot to enable SSLProxyEngine. Just enabled it and its working like a charm.
Edit for HTTPs portion.
<VirtualHost *:443>
ServerAdmin your_email_address
ServerName wordpress.myorg.com
ServerAlias wordpress.myorg.com
SSLEngine on
## Added these lines ##
SSLProxyEngine On
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
## -- ##
SSLCertificateFile /etc/apache2/ssl/myorg.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/myorg.com.key
ProxyRequests On
ProxyVia On
ProxyPass /CAS/ ajp://cas.myorg.com:8009/CAS/
ProxyPassReverse /CAS/ ajp://cas.myorg.com:8009/CAS/
</VirtualHost>
Related
I have installed wamp64. configured various vhosts which work well except for one address which the system forces to go to HTTPS instead of HTTP like the rest of them. dev.test.com is forced to go to HTTPS://dev.test.com instead of HTTP://dev.test.com and of course the file is not found.
dev.test2.com goes to HTTP,
example goes to HTTP
I had a XAMPP install that had a vhosts file which had a redirect for dev.test.com to HTTPS. Thinking this might somehow interfere, I renamed that XAMPP vhost file, but I still get the same problem even after a computer reboot.
In wamp64 I am able to create any other vhost and have it work fine, but not this one. What could be causing this?
wamp64, version 3.2.9, php 7.4, apache 2.4.51
WAMP VHOST FILE:
<VirtualHost *:80>
ServerName example
DocumentRoot "c:/wamp64/www/example"
<Directory "c:/wamp64/www/example/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName dev.test.com
DocumentRoot "c:/wamp64/www/dev.test.com"
<Directory "c:/wamp64/www/dev.test.com/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName dev.test2.com
DocumentRoot "c:/wamp64/www/dev.test2.com"
<Directory "c:/wamp64/www/dev.test2.com/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
My previous XAMPP VHOST FILE - NOW RENAMED TO DISABLE IT (httpd-vhosts_old.conf)
<VirtualHost dev.test.com:80>
ServerName dev.test.com
DocumentRoot "C:\xampp\htdocs\dev.test.com"
<Directory "C:\xampp\htdocs\dev.test.com">
Options All
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/dev.test.com-error.log"
CustomLog "dev.test.com-access.log" combined
#redirect non SSL URI to SSL URI
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.dev.test.com [OR]
RewriteCond %{SERVER_NAME} =dev.test.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
I ended up configuring a local SSL certificate for the server and converted all local hostnames to access SSL which worked fine. I know this does not answer the posted question, but at least allowed me to proceed.
I have to migrate an Apache configuration file to Nginx but as I have no experience in Nginx I would like some help.
This is my apache setup:
000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
<Directory /var/www/ff>
AllowOverride All
Options -Indexes
</Directory>
DocumentRoot /var/www
RedirectMatch ^/$ /ff/
Alias "/uploads" "/var/www/ff/uploads/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I’m a little lost as using the parameter RedirectMatch in nginx, I guess it has another name
help me create a configuration file for nginx?
Regards,
Is it possible to provide the Apache R-mod via TLS directly? Without the need to set up a reverse proxy?
I'm trying to set up an OpenCPU instance without the typical reverse proxy configuration. It should be accessible via HTTPS and HTTPS only.
Whenever I try to enable the TLS/SSL engine, Apache ignores that and on port 443 I'll get a header missmatch as HTTP is delivered over port 443.
<IfModule mod_ssl.c>
SSLStaplingCache "shmcb:${APACHE_LOG_DIR}/stapling-cache(150000)"
<IfModule mod_R.c>
RSourceOnStartup "/usr/lib/opencpu/rapache/onstartup.R"
<Location /ocpu>
SSLEngine on
SSLUseStapling on
SSLCertificateFile /etc/ssl/xxx.pem
SSLCertificateKeyFile /etc/ssl/private/xxx.key
SSLCertificateChainFile /etc/ssl/certs/chain.pem
SetHandler r-handler
RHandler opencpu:::rapachehandler
SetOutputFilter DEFLATE
SetInputFilter DEFLATE
</Location>
Alias /favicon.ico /usr/lib/opencpu/rapache/favicon.ico
Alias /robots.txt /usr/lib/opencpu/rapache/robots.txt
# Increase prefork defaults
<IfVersion >= 2.4>
#StartServers 10
MaxConnectionsPerChild 200
<Directory /usr/lib/opencpu/rapache>
Require all granted
</Directory>
</IfVersion>
</IfModule>
It seems that the Location /ocpu is valid for both VirtualHosts, the one for HTTP and HTTPS.
So it suffices to redirect HTTP to HTTPS in 000-default.conf and to correctly set up TLS in the default-ssl.conf.
<VirtualHost *:80>
ServerName xxx
ServerAdmin xxx
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect / https://xxx/
</VirtualHost>
And
# cat default-ssl.conf
<IfModule mod_ssl.c>
SSLStaplingCache "shmcb:${APACHE_LOG_DIR}/stapling-cache(150000)"
LogLevel Debug
<VirtualHost *:443>
ServerName xxx
ServerAdmin xxx
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLUseStapling on
SSLCertificateFile /etc/ssl/certs/xxx.pem
SSLCertificateKeyFile /etc/ssl/private/xxx.key
SSLCertificateChainFile /etc/ssl/certs/xxx.pem
DocumentRoot /var/www/html
</VirtualHost>
</IfModule>
No need to change anything in the opencpu.conf.
I just got a new domain and i'm trying to use it for a different site but I can't get it to work. It still sends me to my other domain name instead. I try to look it up how to do it but I can't find away to do it, What should I do?? Here is the code,
ServerName dstokesncstudio.org
<VirtualHost 69.132.203.191:80>
ServerName dstokesncstudio.org:80
ServerAlias www.dstokesncstudio.org
DocumentRoot "C:/htdocs/www/dstokesncstudio"
DirectoryIndex index.html
TransferLog "C:/htdocs/www/dstokesncstudio/logs/access.log"
ErrorLog "C:/htdocs/www/dstokesncstudio/logs/error.log"
<Directory "C:/htdocs/www/dstokesncstudio">
DirectoryIndex index.html
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
ServerName dejesusconstruction.com
<VirtualHost 69.132.203.191:8080>
ServerName www.dejesusconstruction.com:8080
ServerAlias www.dejesusconstruction.com
DocumentRoot "C:/htdocs/www/dstokesncstudio/jesus"
DirectoryIndex index.html
<Directory "C:/htdocs/www/dstokesncstudio/jesus">
DirectoryIndex index.html
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 69.132.203.191:80>
ServerName dstokesncstudio.org
</VirtualHost>
<VirtualHost 69.132.203.191:8080>
ServerName dejesusconstruction.com
</VirtualHost>
As
http://ping.eu/nslookup/
say
dstokesncstudio.org => 216.239.38.21,216.239.32.21,...
dejesusconstruction.com => 216.239.38.21,216.239.32.21,...
not 69.132.203.191
I think you want name based virtual hosts https://httpd.apache.org/docs/2.4/vhosts/name-based.html
In your case remove the ServerName ... outside of the VirtualHost ... and add on top
NameVirtualHost *:80
NameVirtualHost *:8080
If you also want to reach the second domain also on port 80 then you dont't need the second line.
Now remove the IP from the VirtualHost as the link above have described and voila you should reach the domains.
I'm setting up 2 wordpress sites. The scenario is that there are two Wordpress installations, in the folder var/www/domain/us and var/www/domain/eu. The domain.com/us should be the default option when you access the site from domain.com
Users access the site through: domain.com/us or domain.com/eu
Right now the setup for virtual host is: (I don't have a real domain name attached, so its only IP address so far)
<VirtualHost *:80>
ServerName [IP-address]
ServerAlias [IP-address]
DocumentRoot /var/www/domain/us
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName [IP-address]/us
DocumentRoot /var/www/domain/us
ServerAlias [IP-address]
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName [IP-address]/eu
DocumentRoot /var/www/domain/eu
ServerAlias [IP-address]
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>
I can access the IP address with the primary virtual host, but the last two IP/us and IP/eu is giving Page not found.
What am I doing wrong?
ServerName interprets the path as part of the hostname. Server name can contain the request scheme, hostname and port, but not the path. Therefore only the first virtual host is valid.
Since you are on Apache 2.4, you can use conditional directives to solve the problem. In the first virtual host add the following, and then remove the other two:
<VirtualHost *:80>
ServerName [IP-address]
ServerAlias [IP-address]
<If "%{REQUEST_URI} =~ m#^/eu.*$#">
DocumentRoot /var/www/domain/eu
</If>
<Else>
DocumentRoot /var/www/domain/us
</Else>
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>