Index: wp-admin/includes/misc.php
===================================================================
--- wp-admin/includes/misc.php	(revision 21157)
+++ wp-admin/includes/misc.php	(working copy)
@@ -19,6 +19,19 @@
 }
 
 /**
+ * Returns whether or not the server supports URL rewriting.
+ *
+ * @since 3.5
+ *
+ * @return bool Whether the server supports URL rewriting
+ */
+function got_url_rewrite() {
+	global $is_nginx;
+	$got_url_rewrite = ( got_mod_rewrite() or iis7_supports_permalinks() or $is_nginx );
+	return apply_filters('got_url_rewrite', $got_url_rewrite);
+}
+
+/**
  * {@internal Missing Short Description}}
  *
  * @since 1.5.0
Index: wp-admin/network.php
===================================================================
--- wp-admin/network.php	(revision 21157)
+++ wp-admin/network.php	(working copy)
@@ -314,7 +314,7 @@
  * @since 3.0.0
  */
 function network_step2( $errors = false ) {
-	global $base, $wpdb;
+	global $base, $wpdb, $is_nginx;
 	$hostname = get_clean_basedomain();
 
 	if ( ! isset( $base ) )
@@ -487,8 +487,32 @@
 		</textarea></li>
 		</ol>
 
-	<?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
+	<?php elseif ( $is_nginx ) : // end iis7_supports_permalinks(). construct nginx configuration instead:
 
+		$nginx_config_file = "location / {\n";
+		$nginx_config_file .= "\t" . 'try_files $uri $uri/ /index.php$is_args$args;' . "\n";
+		$nginx_config_file .= "}\n\n";
+
+		$nginx_config_file .= '# Uploaded files' . "\n";
+		$nginx_config_file .= 'rewrite ^/' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) /wp-includes/ms-files.php?file=$2 last;' . "\n\n";
+
+		if ( ! $subdomain_install ) {
+			$nginx_config_file .= '# Add trailing slash to /wp-admin' . "\n";
+			$nginx_config_file .= 'rewrite /wp-admin$ $scheme://$host$uri/ permanent;' . "\n\n";
+			$nginx_config_file .= 'if (!-e $request_filename) {' . "\n";
+			$nginx_config_file .= "\t" . 'rewrite ^/[_0-9a-zA-Z-]+(/wp-(content|admin|includes).*) $1 last;' . "\n";
+			$nginx_config_file .= "\t" . 'rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;' . "\n";
+			$nginx_config_file .= "}\n";
+		}
+
+	?>
+		<li><p><?php _e( 'Add the following to your <code>nginx.conf</code> file (or equivalent), replacing other WordPress rules:' ); ?></p>
+		<textarea class="code" readonly="readonly" cols="100" rows="20">
+<?php echo esc_textarea( $nginx_config_file ); ?></textarea></li>
+		</ol>
+
+	<?php else : // end nginx. construct an htaccess file instead:
+
 		$htaccess_file = 'RewriteEngine On
 RewriteBase ' . $base . '
 RewriteRule ^index\.php$ - [L]
@@ -515,7 +539,7 @@
 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
 		</ol>
 
-	<?php endif; // end IIS/Apache code branches.
+	<?php endif; // end IIS/nginx/Apache code branches.
 
 	if ( !is_multisite() ) { ?>
 		<p><?php printf( __( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.') ); ?> <a href="<?php echo esc_url( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p>
Index: wp-admin/options-permalink.php
===================================================================
--- wp-admin/options-permalink.php	(revision 21157)
+++ wp-admin/options-permalink.php	(working copy)
@@ -78,7 +78,7 @@
 $iis7_permalinks = iis7_supports_permalinks();
 
 $prefix = $blog_prefix = '';
-if ( ! got_mod_rewrite() && ! $iis7_permalinks )
+if ( ! got_url_rewrite() )
 	$prefix = '/index.php';
 if ( is_multisite() && !is_subdomain_install() && is_main_site() )
 	$blog_prefix = '/blog';
@@ -128,6 +128,8 @@
 		$writable = true;
 	else
 		$writable = false;
+} else if ( $is_nginx ) {
+	$writable = false;
 } else {
 	if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') )
 		$writable = true;
@@ -152,7 +154,12 @@
 			_e('Permalink structure updated. Remove write access on web.config file now!');
 		else
 			_e('Permalink structure updated.');
-	} else {
+		} else if ( $is_nginx ) { 
+			if ( $permalink_structure ) 
+				_e('Permalink structure updated. Ensure your nginx.conf file (or equivalent) contains the rewrite rules below.'); 
+			else 
+				_e('Permalink structure updated.'); 
+		} else {
 		if ( $permalink_structure && ! $usingpi && ! $writable )
 			_e('You should update your .htaccess now.');
 		else
@@ -225,14 +232,9 @@
 </table>
 
 <h3><?php _e('Optional'); ?></h3>
-<?php
-$suffix = '';
-if ( ! $is_apache && ! $iis7_permalinks )
-	$suffix = 'index.php/';
-?>
 <p><?php
-/* translators: %s is a placeholder that must come at the start of the URL path. */
-printf( __('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/%stopics/uncategorized/</code>. If you leave these blank the defaults will be used.'), $suffix ); ?></p>
+/* translators: %s is the site URL. */
+printf( __('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>%s/topics/uncategorized/</code>. If you leave these blank the defaults will be used.'), home_url( $prefix . $blog_prefix ) ); ?></p>
 
 <table class="form-table">
 	<tr>
@@ -269,6 +271,14 @@
 <p><?php _e('If you temporarily make your site&#8217;s root directory writable for us to generate the <code>web.config</code> file automatically, do not forget to revert the permissions after the file has been created.') ?></p>
 		<?php endif; ?>
 	<?php endif; ?>
+<?php elseif ( $is_nginx ) :
+	if ( $permalink_structure && ! $usingpi ) : ?>
+<p><?php _e('These are the rewrite rules you should have in your <code>nginx.conf</code> (or equivalent) file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
+<form action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
+	<p><textarea rows="4" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->nginx_url_rewrite_rules() ); ?></textarea></p>
+</form>
+	<?php endif; ?>
 <?php else :
 	if ( $permalink_structure && ! $usingpi && ! $writable ) : ?>
 <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 21157)
+++ wp-includes/rewrite.php	(working copy)
@@ -1809,6 +1809,27 @@
 	}
 
 	/**
+	 * Retrieve Nginx formatted rewrite rules.
+	 *
+	 * @since 3.5
+	 * @access public
+	 *
+	 * @return string
+	 */
+	function nginx_url_rewrite_rules() {
+		if ( ! $this->using_permalinks() )
+			return '';
+
+		$rules = "location / {\n";
+		$rules .= "\t" . 'try_files $uri $uri/ /index.php$is_args$args;' . "\n";
+		$rules .= "}\n";
+
+		$rules = apply_filters('nginx_rewrite_rules', $rules);
+
+		return $rules;
+	}
+
+	/**
 	 * Add a straight rewrite rule.
 	 *
 	 * Any value in the $after parameter that isn't 'bottom' will be placed at
Index: wp-includes/vars.php
===================================================================
--- wp-includes/vars.php	(revision 21157)
+++ wp-includes/vars.php	(working copy)
@@ -87,6 +87,12 @@
 $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
 
 /**
+ * Whether the server software is Nginx or something else
+ * @global bool $is_nginx
+ */
+$is_nginx = (strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);
+
+/**
  * Whether the server software is IIS or something else
  * @global bool $is_IIS
  */
