Nginx1
ставим
sudo pacman -S nginx
Блок server {...} переносим из /etc/nginx/nginx.conf в /etc/nginx/sites-available/mysitename. А в /etc/nginx.conf добавляем в самом низу блока http:
# include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
Дефолтный конфиг:
worker_processes 1;
include modules.d/*.conf;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
Структура моего проекта примерно такая:
public/
├── main/
│ ├── subpage
│ │ ├── index.html
│ │ └── page1.html
│ ├── index.html
│ ├── page1.html
│ └── page2.html
└── assets/
├── css/
├── js/
└── images/
Поэтому я подправлю конфиг:
worker_processes 1;
include modules.d/*.conf;
events {
worker_connections 1024;
}
http {
# Добавляем размеры хеш-таблицы MIME-типов:
types_hash_max_size 2048;
types_hash_bucket_size 128;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
# Выносим root на уровень папки public:
root /home/mark/projects/node/my.mclang.ru/public;
location / {
try_files /main$uri /main$uri/index.html =404;
}
location /assets/ {
try_files $uri =404;
}
}
}