How to change default port apache is listening to ?

Discussion in 'Developers' Forum' started by Keoz, Dec 3, 2020.

  1. Keoz

    Keoz Member

    Machine : remote VPS SSD
    OS distro : Ubuntu 18.04
    Web server : Apache2
    ISPCongig 3 : last version

    Couple of years ago, I asked if Apache and Nginx may both run on a VPS, and was replied (If I remember correctly) to better not do that, because it may prevent ISPConfig to work correctly (meaning that this may cause bugs, conflicts, failures, or whatever within it…).

    Today, in the purpose to install Azurcast app (webradio), I still tried to do so, following a tutorial instructions (link hereafter), that this sentence is a sample of that makes me felt somehow confident to proceed “For example, you could tell apache to listen on and instruct Nginx to reverse –proxy traffic to Apache while still serving static content“ :

    *** TUTORIAL ***

    *** PROBLEM ***
    While remotly connected to my VPS through local terminal, I entered the command line like shown in the tutorial , to change Apache default port 80 to 8080. But it seems that Apache default port setting is hard-coded : I can’t add, replace, overwrite anything to default port setting (80) :

    command line :
    nano /ect/apache2/ports.conf
    (I can’t modify settings)

    *** Q1 ***
    Why can’t I change this setting, or where else (within what other file) is it possible to do so ?
    *** Q2 ***
    Are there still reasons to consider that having both Apache and Nginx running on same server is a configuration that exceeds or unstablels ISPConfig 3 capacities ?


  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I have not tried this personally, but you could create a custom vhost.conf.master and put it in the conf-custom folder of ISPConfig. In that file you can define custom ports. Make sure apache doesn't run anything on port 80 and 443 (https) anymore and then fire up nginx as reverse proxy. I don't use nginx so not sure what would be the best way to do this. Also, it might be difficult to get HTTPS working properly.
  3. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Running multiple web server softwares in one server with ISPConfig is never recommended nor advisable as ISPConfig will only detect and use one i.e. if both exist, only apache2 will be selected as default webserver.

    @Th0m suggestion to use conf-custom should work but only to the extend that only apache2 web server will be configured and managed by ISPConfig, while you'll need to configure and manage nginx manually.

    That said, long time ago there were attempts to create nginx reverse proxy plugin for ISPConfig so they can be used hand in hand in a server but they were all at the end, abandoned.

    However, there is one other possible way for those with high enthusiasm in this two ISPConfig web servers approach i.e. one server with nginx as reverse proxy / load balancer and the other with apache2 as the pure web server.

    The above last paragraph is just a thought which I think may be easier and more workable with ISPConfig, but may not truely be so too. ;)
  4. Keoz

    Keoz Member

    As for next step, I do try to gain skills that helps to make nginx run as a proxy server for apache2. But it is not that simple, even whith the help of a tutorial (please see my new thread) :

  5. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    Setting up nginx as an rp is actually not difficult at all, nor does the SSL side of things become an issue, that is if you just allow nginx to serve the ssl, If I recall, I was able to proxy pass to none ssl without issue. Don't quote me on that it was some time back and I honestly cannot recall if the browsers bugged out about it.

    I wrote a guide some time back which was more geared toward my single ip address situation as I run my machines on my home network, however I touch on the subject of running two servers on the same host.

    Ignore the parts you don't need its in depth but its also very easy.

    With regard to the ISPConfig side of things, well that would require a script, a slight modification to ISPConfig to run it after a vhost modification as well as custom apache templates in ISPConfig to make the vhosts listen on alternate ports.

    Nginx listen on 80 and 443 forward to say 8000 and 8443
    Apache listen on 8000 and 8443
    ufw blocking both of Apache's alternate ports (doesn't affect localhost connections)
    Script to read apache hosts and modify nginx hosts accordingly then reload.

    To be honest my interest has been piqued by the idea, I think I will add this to my growing list of things I want to do with ISPConfig, who knows it might make it into a release some day. Same server is easy i imagine, separate server not so much because you can't just read the files on the system without ssh (what am i taking about I am already using an NFS Share for acme, this could be done the same way!)
    ahrasis likes this.

Share This Page