I
I
Issue2021-03-27 01:32:56
linux
Issue, 2021-03-27 01:32:56

How to make a subdomain on a separate port in Ubuntu?

There is a site on the Jam.Python web framework , when it starts it takes the address 0.0.0.0 on port 8080 . There is also an Apache
web server with a PHP7 site available at 127.0.0.1 on port 80 . In the /etc/hosts file, I added the address with the application port:


127.0.0.1	  localhost
0.0.0.0:8080	crm.localhost


When running a Python application, it prints out the IP and port:
[email protected]:/var/www/crm$ python server.py 
 * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)


But that didn't work, going to crm.localhost opens the directory /var/www/html/ which should only be accessible to localhost . Why doesn't it work, and how can I assign a subdomain to a separate port?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
I
Issue, 2021-03-27
@paulenot

I solved everything many times easier, without installing anything extra, I posted the following code on a subdomain:

<!DOCTYPE html><html><head>
  <meta charset="utf-8">
  <title>TITLE</title>
  <style type="text/css">
    * {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        border: none;
    }
  </style>
</head><body>
  <iframe src="<?php print($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].':8080'.$_SERVER['REQUEST_URI']) ?>"></iframe>
</body></html>

K
ky0, 2021-03-27
@ky0

Understand first what 0.0.0.0 is and how /etc/hosts works before adding nonsense there.

V
Vladimir, 2021-03-27
@Casufi

you're doing nonsense. Leave hosts alone, take nginx, apache with PHP set to 8081 and configure the rest in nginx

A
Alexey Dmitriev, 2021-03-27
@SignFinder

1. On the second line, you entered fundamentally incorrect information into /etc/hosts.
There can be no ports and 0.0.0.0 to create DNS records also does not need to be done - use either 127.0.0.1 if you need access via localhost, or the ip address of the external interface if you need access over the network.
2. Create a separate VirtualHost in apache for your domain, or use default virtualhost if there is one site.
3. Everyone on the network who will access your domain - you also need to make entries in the local hosts file.

A
AUser0, 2021-03-27
@AUser0

Make /etc/hosts:

127.0.0.1 localhost
127.0.0.1 crm.localhost

and open crm.localhost:8080
PS True localhost:8080 will also work the same (and any other IP address registered on this server), because 0.0.0.0 means "use any available IP addresses".

A
Andrey Gavrilov, 2021-03-27
@thexaver

nginx reverse proxy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question