Project: Share

Objective: By the end of this lesson, you will be able to configure Apache to listen on a new HTTPS port (7199) and forward all traffic to an HTTP service running on port 5199.

Prerequisites:

  • Basic understanding of Apache configuration.
  • Access to Apache configuration files.
  • An active HTTP service running on port 5199.

Lesson Content:

  1. Introduction to Port Forwarding and Apache Configuration:
    • Explanation of port forwarding and its use cases.
    • Overview of Apache as a web server and reverse proxy.
  2. Step 1: Configure Apache to Listen on a New Port (7199):
    • Edit the Apache main configuration file (httpd.conf or apache2.conf).
    • Add the following line to tell Apache to listen on port 7199:
      Listen 7199
    • Save and close the file.
  3. Step 2: Set Up a New VirtualHost for SSL on Port 7199:
    • Navigate to your SSL configuration file (typically located in /etc/apache2/sites-available/ or a similar directory).
    • Create a new VirtualHost block for port 7199 with the following configuration:
      <IfModule mod_ssl.c>
      <VirtualHost *:7199>
      ServerName www.yourdomain.com
      SSLEngine on
      SSLCertificateFile /path/to/your/certificate.crt
      SSLCertificateKeyFile /path/to/your/private.key
      Include /etc/letsencrypt/options-ssl-apache.conf# Reverse Proxy Configuration
      ProxyRequests Off
      ProxyPass / http://localhost:5199/
      ProxyPassReverse / http://localhost:5199/

      <Proxy *>
      Order deny,allow
      Allow from all
      </Proxy>
      </VirtualHost>
      </IfModule>

      Replace /path/to/your/certificate.crt and /path/to/your/private.key with the paths to your SSL certificate and private key.

  4. Step 3: Restart Apache to Apply Changes:
    • Execute the following command to restart Apache:
      sudo systemctl restart apache2
    • This will make Apache start listening on the new port with the specified configuration.
  5. Step 4: Testing the Configuration:
    • Open a web browser and navigate to https://www.yourdomain.com:7199.
    • Verify that the content served is being proxied from the HTTP service running on port 5199.
  6. Step 5: Firewall Adjustments (If Necessary):
    • Ensure that your server’s firewall allows traffic on port 7199.
  7. Conclusion and Troubleshooting Tips:
    • Recap of what we’ve accomplished.
    • Common troubleshooting tips if the setup doesn’t work as expected.
  • Implement the port forwarding setup on your Apache server.
  • Test the configuration by accessing your service at https://www.yourdomain.com:7199.
  • Document any challenges faced and how you resolved them.

Additional Resources:

Feedback and Support:

  • For any queries or issues, consult the Apache community forums or reach out to a network administrator for assistance.