dos2unix filename
sed -i 's/\r$//' filename
sed -i 's/\r//g' file
find . -type f -name '*.php' -exec sed -i -r 's/\r$//g' {} \; - то же самое, но для всех файлов .php в поддиректориях.sed -i 's/\r//g' file
find . -type f -name '*.php' -exec sed -i -r 's/\r$//g' {} \; - то же самое, но для всех файлов .php в поддиректориях.rewrite reg-ex replacement [flag];In the above:
rewrite ^(/data/.*)/geek/(\w+)\.?.*$ $1/linux/$2.html last;For example:
rewrite ^/linux/(.*)$ /linux.php?distro=$1 last;In the above example, when you call thegeekstuff.com/linux/centos URL, it will get rewritten using the above rule and it will serve the page with this rewritten URL: thegeekstuff.com/linux.php?distro=centos
location /data/ {
rewrite ^(/data/.*)/geek/(\w+)\.?.*$ $1/linux/$2.html break;
return 403;
}
This is what would’ve happened if you used “last” flag above:rewrite ^/linux/(.*)$ /linux.php?distro=$1 last;In the above example, when the replacement string include the incoming request arguments, then the arguments from the previous request are appended after them.
rewrite ^/linux/(.*)$ /linux.php?distro=$1? last;In the above example, replacement string include the incoming request arguments, then the arguments from the previous request are NOT appended after them.
if ($scheme = "http") {
rewrite ^ https://www.thegeekstuff.com$uri permanent;
}
if ($http_host = thegeekstuff.com) {
rewrite (.*) https://www.thegeekstuff.com$1;
}
if ($http_user_agent = MSIE) {
rewrite ^(.*)$ /pdf/$1 break;
}
Please note that there are better ways to achieve the end-result of
the above examples. The above examples are just given to show that we
can add rewrite directive inside if statement in the nginx config file.server_name_in_redirect on port_in_redirect off
rewrite ^(/data/.*)/geek/(\w+)\.?.*$ $1/linux/$2.html last;break: This flag will stop the processing of the rewrite directives in the current set.
rewrite ^(/data/.*)/geek/(\w+)\.?.*$ $1/linux/$2.html break;redirect: This flag will do a temporary redirection using 302 HTTP code. This is mainly used when the replacement string is not http, or https, or $scheme
rewrite ^ https://www.thegeekstuff.com$uri permanent;
error_log /var/log/nginx/error.log notice; rewrite_log on;In the above:
[notice] 14385#14385: *1 "^(/data/.*)/geek/(\w+)\.?.*$" matches "/data/distro/geek/test", client: 192.168.101.1, server: localhost, request: "GET /data/distro/geek/test HTTP/1.1", host: "192.168.101.10" [notice] 14385#14385: *1 rewritten data: "/data/distro/linux/test.html", args: "", client: 192.168.101.1, server: localhost, request: "GET /data/distro/geek/test HTTP/1.1", host: "192.168.101.10"In the above:
yum install epel-release. Let’s start installation!yum update -y yum install wget python-setuptools.noarch python2-pip.noarch
python-devel.x86_64 libxslt.x86_64 libxslt-devel.x86_64 libxml2
libxml2-devel.x86_64 libzip libzip-devel libffi.x86_64
libffi-devel.x86_64 openssl-libs.x86_64 libpqxx libpqxx-devel libyaml
libyaml-devel libjpeg libjpeg-devel libpng libpng12 libpng12-devel
libpng-devel net-tools gcc gcc-c++ -yyum install postgresql-server.x86_64 postgresql-contribpostgresql-setup initdb
systemctl enable postgresql.service
systemctl start postgresql.serviceyum install redis
systemctl enable redis.service
systemctl start redis.serviceyum install supervisor
systemctl enable supervisord.servicepip install --upgrade pippip install -U virtualenvuseradd sentrysu - postgres
psql template1
create user sentry with password 'type_your_password';
alter user sentry with superuser;
create database sentrydb with owner sentry;
\q
exitsu - sentryvirtualenv /home/sentry/sentry_appsource /home/sentry/sentry_app/bin/activatepip install -U sentry/home/sentry/sentry_app/bin/sentry init/home/sentry/.sentry/sentry.conf.py
/home/sentry/.sentry/config.ymlDATABASES = {
'default': {
'ENGINE': 'sentry.db.postgres',
'NAME': 'sentrydb',
'USER': 'sentry',
'PASSWORD': 'your_password',
'HOST': '127.0.0.1',
'PORT': '5432',
'AUTOCOMMIT': True,
'ATOMIC_REQUESTS': False,
}
}
the second file:redis.clusters: default: hosts: 0: host: 127.0.0.1 port: 6379Note: please review the other settings in these two files.
# TYPE DATABASE USER ADDRESS METHOD local all postgres peer # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 ident #host replication postgres ::1/128 identRestart postgres:
systemctl restart postgresql.service/home/sentry/sentry_app/bin/sentry upgrade
exitfiles = supervisord.d/*.conf[program:sentry-web] directory=/home/sentry/sentry_app/ environment=SENTRY_CONF="/home/sentry/.sentry" command=/home/sentry/sentry_app/bin/sentry --config=/home/sentry/.sentry run web autostart=true autorestart=true redirect_stderr=true user=sentry stdout_logfile=syslog stderr_logfile=syslog [program:sentry-worker] directory=/home/sentry/sentry_app/ environment=SENTRY_CONF="/home/sentry/.sentry" command=/home/sentry/sentry_app/bin/sentry --config=/home/sentry/.sentry run worker autostart=true autorestart=true redirect_stderr=true user=sentry stdout_logfile=syslog stderr_logfile=syslog startsecs=1 startretries=3 stopsignal=TERM stopwaitsecs=10 stopasgroup=false killasgroup=true [program:sentry-cron] directory=/home/sentry/sentry_app/ environment=SENTRY_CONF="/home/sentry/.sentry" command=/home/sentry/sentry_app/bin/sentry --config=/home/sentry/.sentry run cron autostart=true autorestart=true redirect_stderr=true user=sentry stdout_logfile=syslog stderr_logfile=syslogstart the supervisor after all these operations:
systemctl start supervisord.servicehttp://your_ip_address:9000
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name yoursentry.com;
ssl_certificate /etc/nginx/ssl/yoursentry.crt;
ssl_certificate_key /etc/nginx/ssl/yoursentry.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:128m;
ssl_session_timeout 10m;
location / {
proxy_pass http://sentry;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
# keepalive + raven.js is a disaster
keepalive_timeout 30;
proxy_read_timeout 10s;
proxy_send_timeout 10s;
send_timeout 10s;
resolver_timeout 10s;
client_body_timeout 10s;
# buffer larger messages
client_max_body_size 10m;
client_body_buffer_size 100k;
add_header Strict-Transport-Security "max-age=31536000";
}
}
upstream sentry {
keepalive 1024;
server 0.0.0.0:9000 max_fails=2 fail_timeout=10m;
}