# Domain names pointing with shared AWS instance

**URL:** https://meta.discourse.org/t/domain-names-pointing-with-shared-aws-instance/87520
**Category:** Self-hosting
**Created:** [May 15, 2018, 8:26am UTC](https://meta.discourse.org/t/domain-names-pointing-with-shared-aws-instance/87520 "2018-05-15T08:26:53Z")
**Posts on this page:** 1
**Showing post:** 18

<div class="post-metadata">

### Author: ![jwtan](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@jwtan](https://meta.discourse.org/u/jwtan)
#### Post date: [May 16, 2018, 11:29am UTC](https://meta.discourse.org/t/domain-names-pointing-with-shared-aws-instance/87520/18 "2018-05-16T11:29:49Z")

</div>

I have followed the steps here:

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247):
>
> @pfaffman edited this heavily 2022.02.24. Blame me if it’s broken. If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX or HAProxy proxy in front of the Docker container. NOTE: This is for advanced admins This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working. You cannot use ./discourse-setup to set up Discourse if another server is using port 80 or 443. You will…

and considered the steps here (but didn’t follow fully):  
[https://meta.discourse.org/t/run-discourse-with-or-alongside-existing-apache-sites/19514](https://meta.discourse.org/t/run-discourse-with-or-alongside-existing-apache-sites/19514)

When I run `/var/discourse/launcher enter app` I get:

`which: no docker.io in (/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin)`

When I run `service nginx restart`

```
[root@ip-xxx.xxx.xxx.xxx ec2-user]# service nginx restart
Stopping nginx: [FAILED]
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
                                                           [FAILED]

```

I guess that because port 80 is taken by httpd to serve the currently running Wordpress site.

This is the config in my nginx.conf, this is likely the setting when I was trying to configure to use nginx for the Wordpress site. /var/www/phagerx/htdocs is where the Wordpress installation resides. Shall I change it to point to /var/discourse?

```
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name phagerx.com;
        root /var/www/phagerx/htdocs;
	index index.php;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page 404 /404.html;
            location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;

    server {
        listen 80 ;
        listen [::]:80 ;
    	server_name ask.phagerx.com; # managed by Certbot
        root /var/www/phagerx/htdocs;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page 404 /404.html;
            location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/ask.phagerx.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/ask.phagerx.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}}

```

This is my app.yml:

```
templates:
  - "templates/cron.template.yml"
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  #- "80:80" # http
  #- "443:443" # https

```

This is my discourse.conf:

```
server {
	listen 80; listen [::]:80;
	#listen [::]:80 ipv6only=on default_server;
	server_name ask.phagerx.com; # <-- change this

	location / {
		proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
		proxy_set_header Host $http_host;
		proxy_http_version 1.1;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
	}
}

```

[ask.phagerx.com](http://ask.phagerx.com) is intended to be the Discourse forum and [phagerx.com](http://phagerx.com) is the existing Wordpress site working on httpd.

Would appreciate if you can shed some light on the part that I’ve been missing. I have added a new custom port 101 in my AWS security for Discourse traffic to be routed to if necessary. But I haven’t added this new port in all my Discourse config yet.

---

_[View the full topic](https://meta.discourse.org/t/domain-names-pointing-with-shared-aws-instance/87520)._
