PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] how to redirect different domains to their respective application ports

 September 21, 2022     apache, httpd.conf, spring-boot, virtualhost     No comments   

Issue

I have VPS and currently i am running 5 Spring boot applications on that server along with httpd. all html for those applications are inside their respective jars. All of them having different domain names. So after hitting the dns name it should automatically go that port application, right now i need to specify the port number explicitly like example.com:9090 i tried virtual host in httpd.conf but its not working.

Listen 9001

<VirtualHost *:9001>
    ServerAdmin admin@admin.askcomputers.co.in
    DocumentRoot /var/www/html/example2.com
    ServerName www.example2.com
</VirtualHost>

Solution

I think you should make sure that you have the proper modules installed for httpd:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Then I think you should have 5 VirtualHost sections with reverse proxy setup:

<VirtualHost www.example1.com:80>
    ServerAdmin admin@admin.askcomputers.co.in
    ServerName www.example1.com
    ProxyRequests Off
    ProxyPass / http://localhost:9090
    ProxyPassReverse / http://localhost:9090
</VirtualHost>
...
<VirtualHost www.example5.com:80>
    ServerAdmin admin@admin.askcomputers.co.in
    ServerName www.example5.com
    ProxyRequests Off
    ProxyPass / http://localhost:9094
    ProxyPassReverse / http://localhost:9094
</VirtualHost>


Answered By - DaShaun
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing