Closed r4nd0m123 closed 6 years ago
Do you have a bit more context? What's the primary domain that the WordPress site responds to?
For example I have two DNS A records which point to the same IP address e.g. domain.com. 1800 IN A 127.0.0.1 www.domain.com. 1800 IN A 127.0.0.1
Say I've configured DebOps-WordPress to use www.domain.com for provisioning a host and that works fine. Is there a way to configure this instance to accept requests for domain.com as well?
Yes, you can! If you set wordpress__domain
to domain.com
, it should setup both for you. That said, your site will always redirect to domain.com
. That's how my website is configured. 😄
Did this work @r4nd0m123?
Unfortunately it didn't I've created a test server with the domain someblogger.tk.
inventory/hosts
# This is an Ansible inventory file in INI format. You can define a list of
# hosts and groups to be managed by this particular inventory.
# Hosts listed under [debops_all_hosts] will have common DebOps plays
# ran against them. It will include services such as iptables, DNS, Postfix,
# sshd configuration and more.
#
# View the list here:
# https://github.com/debops/debops-playbooks/blob/master/playbooks/common.yml
[debops_all_hosts]
someblogger.tk
[wordpress]
someblogger.tk
/etc/nginx/sites-available/varnish.someblogger.tk.conf
# This file is managed remotely, all changes will be lost
# nginx server configuration for:
# - http://someblogger.tk/
# generated by Ansible role: carlalexander.wordpress
server {
listen [::]:80 default_server ipv6only=off;
server_name someblogger.tk;
include snippets/acme-challenge.conf;
keepalive_timeout 60;
access_log /var/log/nginx/varnish.someblogger.tk_access.log;
error_log /var/log/nginx/varnish.someblogger.tk_error.log;
client_max_body_size 32M;
if ($host != $server_name) {
return 444;
}
location = /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1/32;
allow ::1/128;
allow 45.77.48.227;
deny all;
}
include /etc/nginx/sites-default.d/*.conf;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port 80;
proxy_pass http://varnish;
}
}
You can't use someblogger.tk
in the hosts
file. DebOps/Ansible needs a full FQDN to work when you connect to the server. The way to do this is as follow:
[debops_all_hosts]
www.someblogger.tk
[wordpress]
www.someblogger.tk
and in your vars.yml
, you want:
wordpress__domain: someblogger.tk
Did this help @r4nd0m123?
I'm interested in figuring this out too.
I'd like to have the "main" URL be www.mysite.com, but also have the server listen on mysite.com and redirect anyone that connects there to www.mysite.com, (so, the opposite of your site, @carlalexander).
I ran everything with the values in the hosts
file as www.mysite.com
, so now www.mysite.com is working, but I'm getting a "connection refused" on the non-www version of the site.
I'm running into some edge cases with this @jbeales. I'll run some tests, but I'm currently away and potentially stranded for the next few days because of Irma. I think you might be able to do it using this configuration:
wordpress__domain: 'www.mysite.com'
wordpress__nginx__server_name: [ 'www.mysite.com', 'mysite.com' ]
I will experiment with that. I saw you were out of town, good luck with the hurricane & stay safe.
Were you able to get this to work @jbeales?
Closing this. Feel free to reopen if there's still an issue @jbeales. 😄
I'll let you know if I run into it. IIRC I ended up fixing it manually somehow in nginx, but the project I was using it on isn't very alive, so I haven't touched the config since, (hence my lack of feedback)!
Is there a way to configure it so nginx listens for requests on the fully qualified domain name and the domain root?
E.g. Instead of
server_name www.domain.com;
Do this
server_name domain.com www.domain.com;