There doesn't appear to be anything wrong with the server block you have used.
I tested the exact block you provided, with a CentOS 6.2 Virtual Machine running nginx 1.0.13 and nginx 1.2.0. I used curl to provide the matching Host header:
curl --header "Host:www.my-domain.com" --head 127.0.0.1
The response showed no error, successfully pointing to the new destination (note the 'Location' header):
HTTP/1.1 301 Moved Permanently
Date: Sun, 29 Apr 2012 18:56:45 GMT
It is worth noting that the dash is a special character in regular expressions, and as a result, does need to be escaped (i.e.
\-) when used in a regex. In your server block, however, neither your server_name nor your rewrite destination are regexes (although, it is possible for a server_name to be a regex).
As an aside, if you aren't using the capture, you can simplify your rewrite to:
rewrite ^ https://www.my-domain.com permanent;
It is quite probable that your redirect has been cached by your browser (it is a 'permanent' redirect, so it could be cached by the browser/ intermediate proxies). Some suggestions for dealing with that may include:
- Force a refresh with: Ctrl+F5
- Clear your browser cache and restart the browser
- Use private browsing mode
- Check the Location header with your developer tools (e.g. Firebug)
- Flush your DNS cache
When testing such configurations, you may want to make a visible change with each modification (e.g. www1 or /test1, etc) so that you can verify that you aren't loading cached content.