webxl / grunt-reload

A grunt task and reverse proxy that enables live reloading of updated files in the browser.
MIT License
132 stars 19 forks source link

Can this be used with PHP sites and Virtual Hosts? #6

Open cerebralideas opened 11 years ago

cerebralideas commented 11 years ago

I use MAMP with virtual hosts using port 80. I can't seem to figure out exactly how to configure the reload config. Here's how I want to write it:

reload: {
    port: 80,
    proxy: {
        host: 'dev.mywebapp.site'
    }
}

This may be a stupid question, but can this also work with PHP sites that don't have a root index.html file?

zigotica commented 11 years ago

+1 on this!

imjared commented 11 years ago

Same issue with the virtual hosts. I've tried using

    reload: {
      proxy: {
        host: 'susydemo'
      }
    },

and my output in terminal is as follows:

Running "reload" task
Proxying http://susydemo:80/
reload server running at http://localhost:8001
imjared commented 11 years ago

Managed to get it working with the following:

    // added server under grunt.initConfig
    server: {
      base: 'http://susydemo'
    },
    reload: {
      proxy: {
        port: 80,
        host: 'susydemo' // is the name of my vhost
      }
    },
    watch:{
        files:['index.html', 'style.less'],
        tasks:'default reload'
    },
    // etc...
cerebralideas commented 11 years ago

Thanks @imjared for sharing your fix, but unfortunately, it didn't work for me. Here's my related grunt config:

server: {
    base: 'http://phi.site'
},
reload: {
    proxy: {
        port: 80,
        host: 'phi.site'
    }
}

I'm still getting the following even after adding the server configuration:

Running "reload" task
Proxying http://phi.site:80/
reload server running at http://localhost:8001

Did you happen to do more than just add the server config? Thanks in advance for any help you may be able to offer :)

imjared commented 11 years ago

Is http://phi.site:80 accessible? If so, try hitting http://phi.site:8001, make a change to index.html with grunt watch running, and hopefully you'll see magic.

If that doesn't work for you, I'm afraid I won't be too much more help :disappointed:

cerebralideas commented 11 years ago

Thanks for the reply @imjared, http://phi.site:80 works, but http://phi.site:8001 does not. I tried adding port: 80 to the grunt file like so:

server: {
    base: 'http://phi.site'
},
reload: {
    port: 80, // added this
    proxy: {
        port: 80,
        host: 'phi.site'
    }
} 

But, that didn't help either. The problem is I'm not familiar with ports and such, so I'm not really sure what the different ports are supposed to reflect. Oh well, thanks for trying to help :)