Showing posts with label configure. Show all posts
Showing posts with label configure. Show all posts

March 03, 2021

Reverse Proxy with IIS ARR (Application Request Routing) and URL Rewrite features

 Dear folks,

Today I am going to explain how we can use the IIS as reverse proxy to secure, redirect the internal application servers.


IIS ARR 3.0 does provide load balancing, cache, forward and reverse proxy features.

This blog will cover the usage of reverse proxy.

Agenda

Secure/Hide the internal servers from public internet requests

Environment Setup

  • DMZ server with IIS ARR and URL Rewrite
  • Internal servers which are accessible to DMZ

Pre-requisites

  1. Make sure the IIS is installed on the server
  2. ARR (Application Request Routing)
  3. URL Rewrite

Procedure

  • Install the pre-requisites
  • Create InBound and OutBound rules to configure as reverse-proxy
  • Edit/Create the web.config based on your requirement
  • Public facing IP - 123.10.1.12
  • Internal IP - 10.1.1.192

Use case 1

  • Redirect URLs with 80 port to internal application server on 8001

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <system.webServer>

    <rewrite>

        <rules>

            <rule name="ReverseProxyInboundRule1" stopProcessing="true">

              <match url="(.*)" />

                        <conditions logicalGrouping="MatchAll">

                           <add input="{CACHE_URL}" pattern="^(https?)://" />

                        </conditions> 

      <action type="Redirect" url="{C:1}://10.1.1.192/{R:1}" />

            </rule>

     </rules>

              <outboundRules>

                <rule name="ReverseProxyOutboundRule" preCondition="IsHTML">

                    <match filterByTags="A, Form, Img" pattern="^http(s)?://10.1.1.192/(.*)" />

                   <action type="Rewrite" value="http{R:1}://123.10.1.12/{R:2}" />

                </rule>

               <preConditions>

                 <preCondition name="IsHTML">

                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />

               </preCondition>

              </preConditions>

            </outboundRules>

           </rewrite>

          </system.webServer>

        </configuration>

Use case 2

  • Redirect URLs with 9001 port to internal application server on 8081 with JSON response

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <system.webServer>

    <rewrite>

        <rules>

            <rule name="ReverseProxyInboundRule_Port_JSON" stopProcessing="true">

              <match url="(.*)" />

      <conditions logicalGrouping="MatchAll">

                <add input="{CACHE_URL}" pattern="^(https?)://" />

              <add input="{SERVER_PORT}" pattern="9001" />

              </conditions>

              <action type="Redirect" url="http://10.1.1.192:8081/{R:1}" />

            </rule>

    </rules>

              <outboundRules>

                <rule name="ReverseProxyOutboundRule_Port_JSON" preCondition="IsJSON">

                    <match filterByTags="A, Form, Img" pattern="^http(s)?://10.1.1.192:8081/(.*)" />

                   <action type="Rewrite" value="http{R:1}://123.10.1.12:9001/{R:2}" />

                </rule>

               <preConditions>

                 <preCondition name="IsJSON">

                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^(text|application/json|application/plaintext" />

               </preCondition>

              </preConditions>

            </outboundRules> 

             </rewrite>

          </system.webServer>

        </configuration>

One can make use of the conditions and redirect accordingly

url

use the regular expression to identify the part of the URL to process further

conditions

 Use conditions with attributes to distinguish the URL

action

redirect, rewrite, abort with specific URL with arguments


Hope this helps organization to configure and secure the servers

Request you to send your valuable feedback and comments to psrdotcom@gmail.com


December 10, 2019

Go language install and configuration in Windows and Visual Studio Code as IDE

Hi folks,

Today I am going to describe you the best way to install and configure the Go language.

Download

From the Go language from its official web page https://golang.org/dl/

After installation, you would be able to program and run the code from any terminal.

What else?

Open your .go file in Visual Studio Code, it asks you something else. What was it?

"The "go-outline" command is not available. Run "go get -v github.com/ramya-rao-a/go-outline" to install."

What you need to do?

First, in Visual Studio Code set the the following in "settings.json" file.

"go.toolsGopath": "C:\\Go"

Note: If you are getting the following error, then click on "Install All"
The "go-outline" command is not available. Run "go get -v github.com/ramya-rao-a/go-outline" to install.

  • Get the location, where it is installing
  • Copy the bin and pkg folder contents to your Go installed folders.
  • Delete the folder which VS Code used to download the content.

That's all.. you should be able to code in Visual Studio Code as well without having 2 different go installed folders.

Happy Go coding!!

Please send your feedback and comments to psrdotcom@gmail.com

September 23, 2019

Add custom user/system attributes in Active Directory

Hi folks,

Today I'll explain the procedure to add and verify the custom user attributes in Active Directory.

Mount the Directory Schema


  1. Open Command Prompt in Administrator mode
    • Start -> cmd -> Right click and select "Run as Administrator"
  2. Mount the directory schema command
    • cmd> regsvr32 schmmgmt.dll
  3. You will be notified with command success pop-up
    • Click on Ok

Creating Custom Attribute


  • Open mmc (Management Console)
  • Click on "File" menu and select "Add/Remove Snap in.."
  • From "Available snap-ins" section, click "Active Directory Schema"
  • Click on "Add"



  • "Active Directory Schema" should be added to "Selected snap-ins" section and click "Ok"
  • You will be viewing the "Active Directory Schema" in the console
  • Expand and select "Attributes"
  • Right click and choose "New" and select "Attribute" as shown below


  • A warning pop-up shows, click Continue


  • Create New Attribute pop-up opens up
  • Enter the custom attribute details
  • Enter the Object ID as per Reference 1


  • Select the Syntax from the list

  • Check Multi-Valued option based on your requirement
  • Click Ok


Adding to User Class


  • Newly created custom attribute has to be mapped to any one of the class (Computer, user etc)
  • To add it to user
  • (Classes -> User -> Properties -> "Add")
  • Select the custom attribute

Restarting ADDS (Active Directory Domain Service)

  • Open Services
  • Start -> Run -> services.msc
  • Navigate to Active Directory Domain Service
  • Restart the service

Verification

  • Open "Active Directory Users and Computers"
  • Go to "Users"
  • Click on any user and view properties
  • Click on "Attribute Editor" tab
  • Navigate to your custom tab

Please send your feedback to psrdotcom@gmail.com

November 21, 2018

Connect to remote Oracle database server from RedHat Linux 7 using Oracle InstaClient

Hi friends,

I have come across a situation, where I need to connect to remote Oracle database server from RedHat Enterprise Linux (RHEL) 7. I found a way of using the Oracle InstaClient instead of installing the full Oracle DB which internally consists of Client.

Pre-requesites


  1. Linux mahcine (I tried with RHEL 7) with following softwares
    • Java (JAVA_HOME should be available)
    • Development Tools (RHEL 7 tools like gcc etc.)
  2. Another machine where Oracle server is installed with the following config
    • Database schema should be available
    • Users should be available instead of system/sysdba users
  3. Both machines shall be reachable to each other via ping.

Note: You should know the database server SID/service name.

Procedure

Download


  1. Download the insta client from Oracle Official Page
  2. In my case, I have downloaded the "Instant Client for Linux x86-64"
  3. Accept the license agreement
  4. Click "oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm" to download
  5. Optionally, you can download the "oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm" to have sqlplus command line utility for testing
  6. Alternatively, you can download the zip files and download the same to install.
  7. In my case, I am going with RPMs.

Install


  • Install the downloaded RPMs
    • #> yum install oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
    • #> yum install oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm
  • While installing, it asks for locations, accept the defaults by pressing the "Enter" button

Note: If any dependencies are there, please install those.

Environment Variables


  • Create a oracle_env.sh file and setup your variables
    • #> gedit /etc/profile.d/oracle_env.sh
    export ORACLE_HOME=/usr/lib/oracle//client/
    export TNS_ADMIN=/usr/lib/oracle//client/
    export PATH=$ORACLE_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH



    • Save your file
    • Source your file with following command
      • #> source /etc/profile.d/oracle_env.sh

    tnsnames.ora


    • Create tnsnames.ora file in your $ORACLE_HOME with following syntax

    localsid = (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))
        (CONNECT_DATA =
          (SID = )
        )
      )

    • Instead of SID, you can use SERVICE_NAME also.

    Connect


    • You can test the connection
      • #> sqlplus @


    You should be able to connect to your remote database.

    Hope, it is useful for you.

    Please send your comments and feedback to psrdotcom@gmail.com

    November 20, 2018

    Completely uninstall openjdk in RedHat Enterprise Linux (RHEL)

    Hi all,

    Today, I'll explain how to uninstall completely the openjdk from the RedHat Enterprise Linux (RHEL) machine.

    Some of the softwares requires only the Oracle Java and having the openjdk, sometimes causes an issue. So, some users wants to remove the openjdk from the linux machine.

    Pre-requisites


    • openjdk installed on the machine
    • Check for java alternatives, when multiple java versions installed
    • #> /usr/sbin/alternatives --config java
    • Result with + is the currently selected java for the machine


    Procedure


    1. Find out the installed openjdk versions

    #> rpm -qa | grep java
    #> rpm -qa | grep jdk

    Sample Output:

    java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64
    java-1.8.0-openjdk-headless-1.8.0.191.b12-1.el7_6.x86_64


    2. Remove the all openjdk versions

    #> yum remove <>

    Example:
    #> yum remove java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64
    #> yum remove java-1.8.0-openjdk-headless-1.8.0.191.b12-1.el7_6.x86_64

    Hope, it is useful for you to configure java on your linux machine.

    Please send your feedback and comments to psrdotcom@gmail.com

    December 14, 2014

    Install and configure latest Oracle Java JDK 8 and 7 in Ubuntu

    Hi friends,

    Today, I'll try to explain the way how to install the latest Oracle Java JDK 8 and 7.

    Pre-requisites

    Ubuntu 12.02 or above

    Procedure

    We can install in two ways
    1. Using PPA
    2. Manual Installation

    PPA installation

    • Open terminal from "Applications" or press key combination "Ctrl+Alt+T"
    • Type the following commands in sequence
      • $ sudo apt-add-repository ppa:webupd8team/java
      • $ sudo apt-get update
    • To install latest JDK 8, type the following command
      • $ sudo apt-get install oracle-java8-installer
    • To install latest JDK 7, type the following command
      • $ sudo apt-get install oracle-java7-installer
    • Once the download complete, it will ask for agree for terms and conditions
    • Click on "OK" to complete the installation

    Manual Installation

    • Download the Oracle JDK from the following official link
    • Extract the downloaded zip (Example "jdk-1.8.0.25.tar.gz")
    • It will create a folder with name "jdk-1.8.0.25"
    • Create a folder "java-8-oracle" under "/usr/lib/jvm" folder
      • $ sudo mkdir -p /usr/lib/jvm/java-8-oracle
    • Move the folder contents to /usr/lib/jvm/java-8-oracle
      • $ mv jdk-1.8.0.25/* -rf /usr/lib/jvm/java-8-oracle/

    Configure the java executables

    Configuration can only be done if more than one JDK is installed.

    To configure java execute the following command

    $ sudo update-alternatives --config java

    Example output if Java 7 and Java 8 installed
    There are 2 choices for the alternative java (providing /usr/bin/java).

      Selection    Path                                     Priority   Status
    ------------------------------------------------------------
      0            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         auto mode
      1            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         manual mode
    * 2            /usr/lib/jvm/java-8-oracle/jre/bin/java   1         manual mode

    Similar way you can do for javac, javaws and other executables

    Configure javac

    $ sudo update-alternatives --config javac

    Configure javaws

    $ sudo update-alternatives --config javaws

    Happy java coding guys :)

    References

    1. http://askubuntu.com/questions/121654/how-to-set-default-java-version
    2. http://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04
    3. http://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre

    Please send your feedback and comments to psrdotcom@gmail.com

    Featured Post

    Java Introdcution

    Please send your review and feedback to psrdotcom@gmail.com