Reaksiyon uygulamamı webpack-dev-sunucusundan nginx'e geçiriyorum.React-router ve nginx
Ben kök url gittiğinizde "localhost: 8080/login" Ben sadece bir 404 almak ve benim nginx günlüğüne ben almaya çalışırken görüyoruz:
my-nginx-container | 2017/05/12 21:07:01 [error] 6#6: *11 open() "/wwwroot/login" failed (2: No such file or directory), client: 172.20.0.1, server: , request: "GET /login HTTP/1.1", host: "localhost:8080"
my-nginx-container | 172.20.0.1 - - [12/May/2017:21:07:01 +0000] "GET /login HTTP/1.1" 404 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0" "-"
bir bakmak gerekir Nerede düzeltmek mi?
tepki Benim yönlendirici bit şöyle görünür: Böyle
render(
<Provider store={store}>
<MuiThemeProvider>
<BrowserRouter history={history}>
<div>
Hello there p
<Route path="/login" component={Login} />
<App>
<Route path="/albums" component={Albums}/>
<Photos>
<Route path="/photos" component={SearchPhotos}/>
</Photos>
<div></div>
<Catalogs>
<Route path="/catalogs/list" component={CatalogList}/>
<Route path="/catalogs/new" component={NewCatalog}/>
<Route path="/catalogs/:id/photos/" component={CatalogPhotos}/>
<Route path="/catalogs/:id/photos/:photoId/card" component={PhotoCard}/>
</Catalogs>
</App>
</div>
</BrowserRouter>
</MuiThemeProvider>
</Provider>, app);
Ve nginx dosyası:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 8080;
root /wwwroot;
location/{
root /wwwroot;
index index.html;
try_files $uri $uri/ /wwwroot/index.html;
}
}
}
DÜZENLEME:
Ben kurulumunun en zaman çünkü çalıştığını biliyorum Localhost'a gidiyorum: 8080 giriş yapmadan giriş sayfasını da aldım. Bu, localhost'a bir yönlendirme ile değil: 8080/login - bazı tepki kodudur. senin nginx config
"try_files" parametresi URI'lar olmalı ve yol adları olmamalıdır. Deneyin: 'try_files $ uri $ uri//index.html;' –
@RichardSmith Tamam ... Index.html dosyasının yol adı olarak gördüm. Önerdiğin şeyi değiştirmeyi denedim - ama aynı sonucu elde ettim. ##/wwwroot/login "başarısız oldu (2: Böyle bir dosya ya da dizin yok) ## başka önerileriniz var. Tonite dalmaya gidiyorum ... – martin