# Nginx issue with subdomain



## fred974 (May 19, 2014)

Hello everyone,

I have a jailed web server running on FreeBSD 10 ZFS file system. Now that I have finished my website I decided to duplicate it so I can use it as a test environment. I have copied the original NGINX configuration file and changed the server_name and root.

Original wordpressLIVE.site

```
server {
        server_name mysite.com www.mysite.com;
        add_header  Cache-Control "public";
        add_header  X-Frame-Options "DENY";
        limit_req   zone=gulag burst=200 nodelay;
        expires     max;
 
        listen 80;
        listen 443 ssl;
        include conf.d/ssl;
 
        root /usr/local/www/mySite;
        index index.html index.htm index.php;
 
        location = /favicon.ico { return 204; }
 
        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ { deny all; }
 
        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }
 
        location / {
                root /usr/local/www/wordpress/live;
                try_files $uri $uri/ /index.php?$args;
 
                        location ~ \.php$ { include conf.d/php-fpm; }
        }
 
        include conf.d/phpmyadmin;
 
        location ~ \.php$ { include conf.d/php-fpm; }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html { root   /usr/local/www/nginx-dist; }
}
```
DuplicatedwordpressTEST.site

```
server {
        server_name *.mysite.com;
        add_header  Cache-Control "public";
        add_header  X-Frame-Options "DENY";
        limit_req   zone=gulag burst=200 nodelay;
        expires     max;
 
        listen 80;
        listen 443 ssl;
        include conf.d/ssl;
 
        root /usr/local/www/mySite;
        index index.html index.htm index.php;
 
        location = /favicon.ico { return 204; }
 
        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ { deny all; }
 
        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }
 
        location / {
                root /usr/local/www/wordpress/test;
                try_files $uri $uri/ /index.php?$args;
 
                        location ~ \.php$ { include conf.d/php-fpm; }
        }
 
        #include conf.d/phpmyadmin;
 
        location ~ \.php$ { include conf.d/php-fpm; }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html { root   /usr/local/www/nginx-dist; }
}
```

When I go to test.mysite.com, the pages are not showing any images at all. If I remove either wordpressTEST.site to wordpressLIVE.site, everything is back to normal. I would really appreciate some help here as I have been going trough this all day

Thank you in advance,
France


----------



## drhowarddrfine (May 19, 2014)

Can you access the images directly? Such as http://mysite.com/yourimage.jpg. What is the response?

Is there only one IP address? If there's more than one, you need to specify that with the listening port.


----------



## fred974 (May 20, 2014)

drhowarddrfine said:
			
		

> Can you access the images directly? Such as http://mysite.com/yourimage.jpg. What is the response?
> 
> Is there only one IP address? If there's more than one, you need to specify that with the listening port.




Hi @drhowarddrfine. Yes, I only have 1 IP address and 4 domains. When I tried to access the images directly as you suggested, I realized that all my URLs were pointing to mysite.com. When I copied the website, I forgot to update the WordPress Address (URL) and Site Address (URL) in the database. Both sites are working now.

That been said, I'll welcome any better way of doing what I am doing, scripts are welcome


----------

