I have an issue with our website. When accessed via https://website.com all works fine, but accessing it through www.website.com it redirects to the subdomain.
Primary domain virtual hosts file:
<VirtualHost *:8080>
ServerAdmin contact#website.com
DocumentRoot /var/www/html/website/
ServerName website.com
ServerAlias www.website.com
<Directory /var/www/html/website/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName hwebsite.com
ServerAlias www.website.com
DocumentRoot /var/www/html/website/
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:8080/
RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"
SSLEngine On
SSLCertificateFile /etc/ssl/certs/website.com.crt
SSLCertificateKeyFile /etc/ssl/private-key.pem
SSLCertificateChainFile /etc/ssl/website.com.ca-bundle
<Directory /var/www/html/website/>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
</Directory>
</VirtualHost>
Subdomain virtual hosts file:
<VirtualHost *:80>
ServerAdmin contact#website.com
DocumentRoot /var/www/subdomains/sub.website.com/
ServerName sub.website.com
ServerAlias www.sub.website.com
<Directory /var/www/subdomains/sub.website.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName sub.website.com
ServerAlias www.sub.website.com
DocumentRoot /var/www/subdomains/sub.website.com/
ProxyPreserveHost on
ProxyPass / http://localhost:80/
RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"
SSLEngine On
SSLCertificateFile /etc/ssl/certs/sub.website.com.crt
SSLCertificateKeyFile /etc/ssl/private/sub.website.com.key
<Directory /var/www/subdomains/sub.website.com/>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If anybody can shed some light, it would be highly appreciated.
Regards,
Cristi Enache
Related
I am trying to setup a php application on a windows server for a client. But my experience with windows is minimal and I am currently trying to setup the web.config file.
Below is my current htaccess on the linux server. How do I setup the web.config file and do I place this on the website root folder as as htaccess?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
So after research I found some answers and below is the file that worked for me on a zend framework application. Hope this will help someone trying to setup a zend app on a windows server.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Ignore files on the filesystem" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" />
</conditions>
<action type="None" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^.*$" />
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I've created a new website and some old links don't work so I want to redirect those links to my new homepage with anchor tags. I have tried so many code snippets but nothing is working. Can anyone see what I've done wrong (I'm not a programmer) thanks! -
I just get:
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
Here is my code:
<location path="page_contact.html">
<system.webServer>
<httpRedirect enabled="true" destination="http://www.mywebsite.com/index.html#contact" httpResponseStatus="Permanent" />
</system.webServer>
</location>
<location path="portfolio.html">
<system.webServer>
<httpRedirect enabled="true" destination="http://www.mywebsite.com/index.html#portfolio" httpResponseStatus="Permanent" />
</system.webServer>
</location>
I have a simple website with a few pages, I just want all the other requests to be redirected to index page instead of showing 404 page.
My host is a plesk and I've built site with
That is how WordPress works - all requests to non-existent files or directories are redirected to index.php, processing second part of URL as an argument for index.php script.
On Plesk for Linux, You can add required directives to the additional section in Domains > example.com > Apache and Nginx Settings. On Windows - to web.config file in the document root.
Apache mod_rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Nginx rewrite:
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php last;
}
IIS URL rewrite:
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
I want to set up a standalone Wildfly cluster with 2 nodes. For this purpose I set up 2 fedora22 virtual machines. On both nodes I installed Wildfly 9.0.0.Final and run it with standalone-ha.xml configuration file. On first node I also installed httpd 2.4 and mod_cluster 1.3.1. Current setting are listed below.
On both machines I disabled firewall and SELinux.
Node1 configuration (192.168.2.240)
mod_cluster.conf
LoadModule cluster_slotmem_module modules/mod_cluster_slotmem.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
LoadModule manager_module modules/mod_manager.so
CreateBalancers 1
<IfModule manager_module>
Listen 192.168.2.240:6666
ManagerBalancerName mycluster
<VirtualHost 192.168.2.240:6666>
KeepAliveTimeout 300
MaxKeepAliveRequests 0
AdvertiseFrequency 5
ServerAdvertise On
EnableMCPMReceive
<Location />
Require all granted
</Location>
<Location /mod_cluster_manager>
SetHandler mod_cluster-manager
Require all granted
</Location>
</VirtualHost>
httpd.conf
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root#localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel debug
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
#Includes mod_cluster.conf
IncludeOptional conf.d/*.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://mycluster
<Location />
Require all granted
</location>
</VirtualHost>
standalone-ha.xml (I am pasting only important parts)
<?xml version='1.0' encoding='UTF-8'?>
<server name="node1" xmlns="urn:jboss:domain:3.0">
<subsystem xmlns="urn:jboss:domain:modcluster:2.0">
<mod-cluster-config advertise-socket="modcluster" connector="ajp">
<dynamic-load-provider>
<load-metric type="cpu"/>
</dynamic-load-provider>
</mod-cluster-config>
</subsystem>
<subsystem xmlns="urn:jboss:domain:undertow:2.0">
<buffer-cache name="default"/>
<server name="default-server">
<ajp-listener name="ajp" socket-binding="ajp"/>
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="cloudflow" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/9"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:192.168.2.240}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:192.168.2.240}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="jgroups-mping" port="0" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
<socket-binding name="jgroups-tcp" port="7600"/>
<socket-binding name="jgroups-tcp-fd" port="57600"/>
<socket-binding name="jgroups-udp" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
<socket-binding name="jgroups-udp-fd" port="54200"/>
<socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
Node2 configuration (192.168.2.226)
<?xml version='1.0' encoding='UTF-8'?>
<server name="node2" xmlns="urn:jboss:domain:3.0">
<subsystem xmlns="urn:jboss:domain:modcluster:2.0">
<mod-cluster-config advertise-socket="modcluster" connector="ajp">
<dynamic-load-provider>
<load-metric type="cpu"/>
</dynamic-load-provider>
</mod-cluster-config>
</subsystem>
<subsystem xmlns="urn:jboss:domain:undertow:2.0">
<buffer-cache name="default"/>
<server name="default-server">
<ajp-listener name="ajp" socket-binding="ajp"/>
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="cloudflow" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/9"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:192.168.2.226}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:192.168.2.226}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="jgroups-mping" port="0" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
<socket-binding name="jgroups-tcp" port="7600"/>
<socket-binding name="jgroups-tcp-fd" port="57600"/>
<socket-binding name="jgroups-udp" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
<socket-binding name="jgroups-udp-fd" port="54200"/>
<socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
my application settings
pom.xml
<contextRoot>/</contextRoot>
jboss-web.xml
<jboss-web>
<context-root>/</context-root>
<virtual-host>cloudflow</virtual-host>
</jboss-web>
jboss-web.xml
<distributable />
I start httpd with systemctl start httpd and then i run Wildfly with ./standalone.sh -c standalone-ha.xml.
Servers starts without an error and deploy application. I can see my application on both nodes on localhost:8080
On 192.168.2.240:6666/mod_cluster_manager i can see following screen:
When i want to get my app in browser on address http://192.168.2.240/ but i get 503 Service Unavailable when i restart httpd and page 404 - Not found few seconds letter.
On http://192.168.2.240:6666/ i get fedora test page. Error log of httpd dont show any error only debug messages.
I think i have problem in configuration where my app gets deployed.
Problem was on command: ServerAdvertise On I changed it to: ServerAdvertise On IP:6666
I also delelted whole virtual Host section for port 80 in httpd.conf
After that it worked
I am trying to make Jboss-7 deployment work with mod_proxy on port 80, but I faced problem
1- I modified the standaloan.xml
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<virtual-server name="default-host" enable-welcome-root="true" default-web-module="filemanager">
<alias name="localhost"/>
<alias name="example.com"/>
</virtual-server>
<virtual-server name="AyeServer" default-web-module="mydeployemnt">
<alias name="mydomain.com"/>
</virtual-server>
</subsystem>
2- I created jboss-web.xml inside WEB-INF with this content
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_7_1.xsd">
<context-root>/</context-root>
<virtual-host>www.mydomain.com<virtual-host>
</jboss-web>
3- in httpd.conf I add to the end of file this content
<VirtualHost *:80>
ServerName mydomain.com
ProxyPreserveHost On
ProxyPass / http://localhost:8080/mydeployment
ProxyPassReverse / http://localhost:8080/mydeployment
DocumentRoot /var/www
<Directory /var/www>
Options -Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
but nothing work when I call mydomain.com
any help?
Thanks
<IfModule !proxy_ajp_module>
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
</IfModule>
ProxyPass / ajp://localhost:8009/
As I understand from your comments, you want to configure apache in front of JBOSS 7, to take the web requests.
You can use mod proxy apache modules with ajp protocol and enable ajp in JBOSS 7 app server. Below are the steps,
Enable below modules in httpd.conf of apache.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
Create a file proxyajp.conf and place in apache/conf folder. The file should have above xml content. Then include this file in httpd.conf.
Modify JBOSS 7 standalone.xml to include supprot for ajp protocol. The ajp port will be 8009.