How to rewrite / proxy an Apache URI to an application listening on a specific port / server?

后端 未结 1 1047
一个人的身影
一个人的身影 2021-01-02 01:39

They say that Apache\'s mod_rewrite is the swiss-army knife of URL manipulation, but can it do this?

Lets say I want to add a new application to my Apache webserver,

相关标签:
1条回答
  • 2021-01-02 02:13

    Using mod_proxy would work just fine. For instance, I mapped https://localhost/yalla/ to point to a subdirectory of my webserver:

    LoadModule proxy_module modules/mod_proxy.so
    ProxyRequests On
    <Proxy *>
          Order deny,allow
          Allow from localhost
    </Proxy>
    ProxyPass /yalla/ http://yalla.ynfonatic.de/tmp/
    

    If you implement this, you'll note that the pictues of the directory-listing aren't visible; this is because they're below the /tmp/ directory on the remote server, hence not visible.

    So, in your case you'd do:

    LoadModule proxy_module modules/mod_proxy.so
    ProxyRequests On
    <Proxy *>
          Order deny,allow
          Allow from localhost # Or whatever your network is if you need an ACL
    </Proxy>
    ProxyPass /app/ http://hostname.example.com:8080/
    

    Like with everything in Apache configuration, watch those trailing slashes when referring to directories.

    Good luck! Alex.

    0 讨论(0)
提交回复
热议问题