#               default server
# ===========================================================
<VirtualHost *:80>
	#www
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/builds/main/build
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =pajoohyar.com
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               dl service
# ===========================================================
<VirtualHost *:80>
        ServerName dl.pajoohyar.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/newpajoohyar/
        AliasMatch ^/sites/all/libraries/app/updater/(.*)$ /var/www/html/newpajoohyar/updates/client-update/$1

        <Directory /var/www/html/newpajoohyar/updates/client-update>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/dlerror.log
        CustomLog ${APACHE_LOG_DIR}/dlaccess.log combined
</VirtualHost>
# ===========================================================
#               narenji service
# ===========================================================
<VirtualHost *:80>
	ProxyPreserveHost On
	ProxyRequests Off
        ServerName site.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/narenji/public
	ProxyPass /socket http://localhost:5156
	ProxyPassReverse /socket http://localhost:5156
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =site.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               wiki service
# ===========================================================
<VirtualHost *:80>
        ServerName wiki.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/wiki/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =wiki.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               dev service
# ===========================================================
<VirtualHost *:80>
        ServerName dev.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/newpajoohyar/site/builds/test-branch/build
        ErrorLog ${APACHE_LOG_DIR}/deverror.log
        CustomLog ${APACHE_LOG_DIR}/devaccess.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =dev.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               site service
# ===========================================================
<VirtualHost *:80>
        ServerName pajoohyar.ir
        ServerAdmin webmaster@localhost
	RedirectMatch ^/sites/all/libraries/app/updater/(.*)$  https://dl.pajoohyar.com/sites/all/libraries/app/updater/$1
	RedirectMatch ^/download/xpdf/(.*)$ https://dl.pajoohyar.com/download/xpdf/$1
        DocumentRoot /var/www/html/pajoohyar/main/build
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:80>
        ServerName www.pajoohyar.ir
        ServerAdmin webmaster@localhost
        RedirectMatch ^/sites/all/libraries/app/updater/(.*)$ http://pajoohyar.ir/sites/all/libraries/app/updater/$1
        DocumentRoot /var/www/html/pajoohyar/main/build
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =www.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               blog service
# ===========================================================
<VirtualHost *:80>
        ServerName blog.pajoohyar.ir
        ServerAdmin webmaster@localhost

	RewriteEngine On
	
	RewriteCond %{QUERY_STRING} p=(\d+) [NC]
	RewriteRule (.*) https://pajoohyar.ir/blog/post/%1? [R=301,L]
	RewriteCond %{QUERY_STRING} (.*) [NC]
        RewriteRule (.*) https://pajoohyar.ir/blog/%1? [R=301,L]
	#Redirect ^[/][?][p][=]$ https://dev.pajoohyar.ir/blog/post/	
        Redirect / https://dev.pajoohyar.ir/blog/
	#ProxyPreserveHost On
        #ProxyPass /?p= https://dev.pajoohyar.ir/blog/post/
        #ProxyPassReverse /?p= https://dev.pajoohyar.ir/blog/post/
	ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteCond %{SERVER_NAME} =blog.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               core service
# ===========================================================
<VirtualHost *:80>
        ServerName core.pajoohyar.ir
        ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html/newpajoohyar/core/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =core.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#              lib-core service
# ===========================================================
<VirtualHost *:80>
        ServerName lib-core.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/online-library-backend-laravel/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =lib-core.pajoohyar.ir
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#             dev-lib-core service
# ===========================================================
<VirtualHost *:80>
        ServerName dev-lib-core.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/dev-online-library-backend-laravel/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =dev-lib-core.pajoohyar.ir
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#             dev-core service
# ===========================================================
<VirtualHost *:80>
        ServerName dev-core.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/dev-core/public
	#ProxyPass / http://127.0.0.1:8000/
        #ProxyPassReverse / http://127.0.0.1:8000/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =dev-core.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               cite service
# ===========================================================
#<VirtualHost *:80>
#        ServerName cite.pajoohyar.ir
#	ServerAdmin webmaster@localhost
#	DocumentRoot /var/www/html/pajoohyar/builds/cite/build
#        ErrorLog ${APACHE_LOG_DIR}/error.log
#        CustomLog ${APACHE_LOG_DIR}/access.log combined
#	RewriteEngine on
#	RewriteCond %{SERVER_NAME} =cite.pajoohyar.ir
#	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
#</VirtualHost>
# ===========================================================
#               newsletter service
# ===========================================================
<VirtualHost *:80>
        ServerName newsletter.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/narenji-front/build/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =newsletter.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               cloud service
# ===========================================================
<VirtualHost *:80>
        ServerName cloud.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/cloud/build/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =cloud.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               dev mylib service
# ===========================================================
<VirtualHost *:80>
        ServerName dev-mylib.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/builds/mylib-dev/build
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =dev-mylib.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               mylib service
# ===========================================================
<VirtualHost *:80>
        ServerName mylib.pajoohyar.ir
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/builds/mylib/build
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =mylib.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               mysql (phpmyadmin) service
# ===========================================================
<VirtualHost *:80>
        ServerName mysql.pajoohyar.ir
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/phpmyadmin
	#ProxyPreserveHost On
	#ProxyPass / http://172.23.0.1:8080/
	#ProxyPassReverse / http://172.23.0.1:8080/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =mysql.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               dev cite service
# ===========================================================
<VirtualHost *:80>
        ServerName dev-cite.pajoohyar.ir
	ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pajoohyar/dev-cite/build
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =dev-cite.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ===========================================================
#               popup service
# ===========================================================
<VirtualHost *:80>
        ServerName popup.pajoohyar.ir
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html/pajoohyar/extenral-popup
	ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =popup.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# ==========================================================
#                      meta data service
#===========================================================
<VirtualHost *:80>
	ServerName metadata.pajoohyar.ir
	ProxyPreserveHost On
        #ProxyPass /api/ http://localhost:5050/
        #ProxyPassReverse /api/ http://localhost:5050/
	ProxyPass / http://localhost:3001/
	ProxyPassReverse / http://localhost:3001/
	ServerAdmin webmaster@localhost
	#DocumentRoot /var/www/html/pajoohyar/metadata/build
	ErrorLOg ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
	Options Indexes MultiViews
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =metadata.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

#<VirtualHost *:80>
#	ServerName metadata.pajoohyar.ir
#	ProxyPreserveHost On 
#	ProxyPass /api/ http://localhost:5050/
#       ProxyPassReverse /api/ http://localhost:5050/
#	ServerAdmin webmaster@localhost
#	DocumentRoot /var/www/html/pajoohyar/site-inoor
#	ErrorLOg ${APACHE_LOG_DIR}/error.log
#	CustomLog ${APACHE_LOG_DIR}/access.log combined
#</VirtualHost>

# ==========================================================
#                  
# ==========================================================
#                      updateField service
#===========================================================
<VirtualHost *:80>
        ServerName update.pajoohyar.ir
        ProxyPreserveHost On
        #ProxyPass / http://localhost:6060/
        #ProxyPassReverse /  http://localhost:6060/
	ProxyPass / http://localhost:3001/
        ProxyPassReverse /  http://localhost:3001/
	ProxyPass /send http://localhost:3001/
        ProxyPassReverse /send  http://localhost:3001/
        ServerAdmin webmaster@localhost
       
        ErrorLOg ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =update.pajoohyar.ir
	RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
