I have my website (Wordpress) and Discourse forum sharing the same AWS instance with the same public ip address. The website has the domain name while Discourse forum has its subdomain. Both domain names point to the same public ip address (set in GoDaddy), my app.yml has the subdomain name for discourse forum set.
This probably isn’t the right settings because after rebuilding app both the main domain and subdomain (supposed to go to Discourse) go to my website. Discourse is no where to be seen.
Am I missing something in the setting? Can you shed some light?
I can’t seem to get Wordpress working in nginx.
Can I have both nginx and httpd running at the same time? While nginx listen to Discourse traffic and httpd listen to Wordpress site traffic.
In my setup, both, wordpress and discourse live under the same nginx happily.
If you’re technically sound, you may want to run httpd on port 81 and then internally proxy it from nginx but I wonder what performance benifit would it bring. However, what kind of issue you’re having may help you find your solution better.
That is totally doable but why do you want to add another variable in the form of httpd when nginx can happily handle both discourse and wordpress at the same time.
That is totally doable but why do you want to add another variable in the form of httpd when nginx can happily handle both discourse and wordpress at the same time.
Totally agree on this. Have been trying to get Wordpress working in nginx for hours. It’s either my nginx.conf isn’t set right or I missed something somewhere. When access the site with the domain name, instead of loading the default homepage, it loads index.html instead. Changing some config causes it to download the content in index.php instead and nothing show on the browser. The other pages just wouldn’t load, 404 error. I suspect the system can’t recognize anything php. Do I need to install a separate php package for Wordpress to work in nginx? Did tried to install php5-fpm but AWS doesn’t has that package. If it does install, will it mess up the php package that’s already working well with httpd?
Apology for having so many questions, I guess you can tell how confused I am.
Decided to revisit the idea of having Wordpress website runing on httpd and Discourse running on nginx.
Tried to install php on nginx but apparently some of the packages is in conflict with existing php that works for httpd. Apparently I need to uninstall php for httpd in order to complete installation for nginx’s php. Fearing that I may mess up the existing Wordpress site and couldn’t get Wordpress sitting on nginx to work in time, I resort to this option again. The current Wordpress site is a live site.
I can extend options that work for a lot of people! .
Modify apache to run on a port other than 80 & 443 then create a server block in nginx that proxies requests back to apache in a format localhost:81
take a backup of your wordpress and configure nginx properly. In case you want me to look at your server, you can drop me a PM here and we can discuss about it. Discourse’s policy restricts any kind of solicitation for work and hence we have to talk about it elsewhere.
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
ask.phagerx.com is intended to be the Discourse forum and 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.
I don’t really understand the point behind complicating things by mixing and matching different examples.
Let me try to break it down as simple as I can.
Discourse won’t run well behind apache. I’ve tried it in past and it is terrible.
Two webservers can’t be made to run together on same machine so No, You can not make it so that apache2 handles wordpress and nginx handles discourse.
You may want to start a 2nd server in case you can’t figure out how to migrate your wordpress from apache2 to nginx
You don’t have to open custom ports for discourse to work as it is talking to nginx over unix sockets by the way that you have configured it. opening more ports is of no use.
now, Coming to the solution part:
If you really love httpd (apache2) you can make it run on port 81 or any other port and then configure nginx to proxy back your wordpress domain’s requests to that port.
If you don’t care what webserver serves your wordpress and just need it to work, take a backup of wordpress, announce a downtime and remove apache & php, configure php-fpm and that should do the trick for you.
if you don’t understand what the heck I’m talking about, better choice will be to spin up a new server and move your discourse or wordpress to that.
Thanks @itsbhanusharma for a good summary.
Yes, I understand what you meant. I agree with you that having nginx to handle both Wordpress site and Discourse is the most efficient way for long term. I don’t develop a special relationship with apache2.
Avoiding a downtime for the live site is what I have been trying to do.
Let me know discuss with the company if a downtime is bearable or we will spin up a new server and I can follow the standard Discourse installation.
Your input has helped me learned a lot and I very much appreciate that. Will be in touch with you if we need your help.