Why would changing ports from 80 to 8080 cause wordpress to act unexpectedly?

I am trying to setup Varnish, which requires Apache to listen on another port that's not 80, so I chose 8080.

However, Wordpress is working very unexpectedly. The index page shows, but it's broken, and all css, js, and other assets show 404 errors.

This seems very different than what happens with other sites such as Drupal or even static pages where all links and assets automatically default to the 8080 port number.

Why would Wordpress not follow these standards? How do I make it "behave?" I have read online that some people solve this by putting :8080 after the URL in settings. That means I have to go in and manually configure over 50 wordpress sites, which doesn't feel right at all.

What's the best way to approach this? If you've installed varnish before, how did you configure your wordpress sites to work correctly?

Topic varnish apache wp-config Wordpress

Category Web


[I stumbled on this thread while looking for WordPress trouble opening on new port. I realized it is about Varnish. My bad.]

WordPress also has trouble opening on new http port too. 1. XAMPP installed on local machine, default settings..Apache accessible on localhost (80), so are all the sites under htdocs, including WordPress sites.

  1. Had to install Skype so I did.Then changed the Apache listen port from 80 to 8080.

  2. Other sites works okay on localhost with port 8080 except WordPress sites. Drupal and other CMS opens just fine even after the port change.

When accessing WordPress sites with the URL localhost with port 8080, it redirects to localhost. Browser returns 404 not found. So why does the other CMS works fine even after the port change from 80 to 8080 but not WordPress.

Anyway, this works: Export the WordPress DB as SQL > Open in text editor > Find and replace all "localhost" with "localhost:8080" > Import. http://techubber.blogspot.in/2016/04/wordpress-site-not-accessible-on-localhost-8080-redirects-to-localhost-404-error.html

Some visitors claimed the workaround mentioned here worked for them (wp_options > siteurl and home edits required): marvintam[dot] com/2009/05/wordpress-on-localhost-port-number/


The problem is not in WordPress, it is in your Varnish or Apache configuration.

Static files, such as CSS, JS, Images, these are served by Apache without going through WordPress at all. WordPress will simply use whatever URL you configure it to use. It doesn't care about port or domains, as such.

So, if your request to your site to get the CSS is returning a 404, why is it doing that? WordPress is not involved, the .htaccess rules WP uses say for Apache to serve any files that exist directly. Take WordPress out of the equation, and just look at why you can't get the CSS file from that URL.


Did you changed the Wordpress URL in Settings->General?

http://example.com/wp => http://example.com:8080/wp

I didn't try, but it should be the same as moving a wp-installation to another domain.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.