Skip to main content

the avatar of Chun-Hung sakana Huang

AWS Elastic Load Balancing with openSUSE instance in AWS 測試小記

AWS Elastic Load Balancing with openSUSE instance in AWS 測試小記

OS: openSUSE Leap 15
AWS CLI: 1.16.135

準備工作:

參考昨天自己的筆記建立兩個 openSUSE instances in AWS

因為要測試 Load Balancing
建立的 EC2 instance 分別隸屬於不同的 subnet ( 不同的 Availability Zone )


兩台 openSUSE Leap 15 instance ( 兩台 instances 都要做 )

==== 在 openSUSE instances 內 ====

切換成 root
>  sudo  su -

安裝 apache2 套件
# zypper  install  apache2

Building repository 'openSUSE-Leap-15.0-Non-Oss' cache ..................................................................................................[done]
Building repository 'openSUSE-Leap-15.0-Oss' cache ......................................................................................................[done]
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 11 NEW packages are going to be installed:
 apache2 apache2-prefork apache2-utils git-web libapr-util1 libapr1 libbrotlicommon1 libbrotlienc1 libgc1 system-user-wwwrun w3m

The following recommended package was automatically selected:
 w3m

11 new packages to install.
Overall download size: 3.3 MiB. Already cached: 0 B. After the operation, additional 8.8 MiB will be used.
Continue? [y/n/...? shows all options] (y):  Y

啟動 apache 服務 ( Web )
# systemctl  start  apache2

觀察服務狀態
# systemctl  status  apache2

● apache2.service - The Apache Webserver
  Loaded: loaded (/usr/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
  Active: active (running) since Sat 2019-04-06 11:29:18 UTC; 3s ago
Main PID: 2000 (httpd-prefork)

設定開機啟動服務
# systemctl  enable  apache2

Created symlink /etc/systemd/system/httpd.service → /usr/lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/apache.service → /usr/lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /usr/lib/systemd/system/apache2.service.

建立測試網頁 ( 不同 site 帶不同的數字 )
# vi   /srv/www/htdocs/index.html

<html> This is site 1 </html>

=============================

接下來在建立一個 security group 可以允許 port 80 連入

> aws ec2 create-security-group --group-name  testweb-sg  --description  "Test Web"

> aws ec2 authorize-security-group-ingress  --group-name  testweb-sg --protocol  tcp  --port  80 --cidr  0.0.0.0/0

接下來使用 aws 指令來將剛剛的 instance 掛上 test-sg ( port 22 ) 以及 testweb-sg ( port 80 )兩個 security group

針對兩個 instance 來修改
> aws ec2 modify-instance-attribute --instance-id  i-0563bb05f74c6d4d3 --groups "sg-09422cde3af0f76cb" "sg-0e725fc07ae70c8a8"

> aws ec2 modify-instance-attribute --instance-id i-06bfb784bea733d7b --groups "sg-09422cde3af0f76cb" "sg-0e725fc07ae70c8a8"

  • Instance-id 請換成自己的 id
  • --groups 後面請填上 security-group-id


測試網站存取
針對兩個 instance 的 Public IP 來存取




參考官方文件:

驗證是否有支援 ELB
> aws elbv2  help

如果有出現指令說明就是有支援

使用 aws 指令 建立 load balancer
> aws  elbv2  create-load-balancer  --name  test-elb --subnets  subnet-92dfe4fb subnet-e4e8989e  --security-groups  sg-0e725fc07ae70c8a8

  • 建立一個 test-elb, 與 2 個 subnet 和 1 個 security group

到 Manage console 觀察
目前的狀態是 provisioning ( 配置 )
Listeners 是空的


使用 aws 指令建立 target group
> aws  elbv2  create-target-group  --name  test-target  --protocol  HTTP --port  80  --vpc-id vpc-c42635ac

  • 這邊要指定 vpc-id 不能使用預設的方式

可以到 Manage console 觀察

順便觀察 Registered targets , 目前為空

接下來用 aws 指令將 instance 註冊到 target
> aws  elbv2  register-targets --target-group-arn arn:aws:elasticloadbalancing:us-east-2:772127831904:targetgroup/test-target/732b4ddaff306e56  --targets  Id=i-0563bb05f74c6d4d3  Id=i-06bfb784bea733d7b

  • Target-group-arn 用剛剛建立起來的 arn
  • --targets 後面接 2 個 openSUSE instance id

再次觀察 Registered targets


最後使用 aws 指令建立 listener

> aws  elbv2  create-listener --load-balancer-arn arn:aws:elasticloadbalancing:us-east-2:772127831904:loadbalancer/app/test-elb/00d35f538d194bd1  --protocol  HTTP  --port 80  --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-2:772127831904:targetgroup/test-target/742b4ddaff306e56


到 Manage Console 觀察 test-elb 的 Listeners


觀察  test-elb 的狀態為 active


點選 Description 觀察 DNS name 並複製 FQDN

開啟瀏覽器
使用 Load balancer 的 FQDN 進行存取測試, 應該會看到向不同 instance 進行存取


今天完成 AWS Load balaner 測試
也是再往前一小步

~ enjoy it


Reference:

the avatar of Bernhard M. Wiedemann

experimental openSUSE mirror via IPFS

The InterPlanetary File System (IPFS) can be used to provide files in a more efficient and distributed way than HTTP.

Our filesystem repo already has the go-ipfs client.

You use it with
ipfs daemon --init

And then you can add my Tumbleweed mirror with
zypper ar http://127.0.0.1:8080/ipns/opensuse.zq1.de./tumbleweed/repo/oss/ ipfs-oss

You can also browse the content online at
http://opensuse.zq1.de./tumbleweed/repo/oss/ . During my testing I found that the results are sometimes inappropriately cached on the Cloudflare CDN, so if you used it under this URL without the ipfs client, this might throw signature errors in zypper.

On the server side, the mirror is updated using the syncopensuse script from
https://github.com/bmwiedemann/opensusearchive and consistency of the repo is verified with checkrepo

When a complete repo was synced, dynaname updates a DNS entry to point to the new head:

> host -t txt _dnslink.opensuse.zq1.de.
_dnslink.opensuse.zq1.de is an alias for tumbleweedipfs.d.zq1.de.
tumbleweedipfs.d.zq1.de descriptive text “Last update: 2019-04-03 12:23:43 UTC”
tumbleweedipfs.d.zq1.de descriptive text “dnslink=/ipfs/QmSXEVuU5z23rDxMyFYDhSAUaGRUPswuSXD3aVsBEzucjE”

If you got spare bandwidth and 300 GB disk on some public server, you could also host a mirror of today’s version, simply by doing ipfs pin add QmSXEVuU5z23rDxMyFYDhSAUaGRUPswuSXD3aVsBEzucjE

This is a permalink: http://127.0.0.1:8080/ipfs/QmSXEVuU5z23rDxMyFYDhSAUaGRUPswuSXD3aVsBEzucjE also browsable via any public IPFS gateway. This means, it will always remain on the 20190401 version of Tumbleweed and no changes in content are possible – similar to how a git commit ID always refers to the same data.

So why did I create this IPFS mirror? That is related to my work on reproducible builds for openSUSE. There it regularly happened that published Tumbleweed binaries were built with libraries, compilers and toolchains that were no longer available in current Tumbleweed. This prevented me from verifying that the published binaries were indeed built correctly without manipulation on the OBS build workers.

Now, with this archive of rpms easily available, it was possible to verify many more Tumbleweed packages than before. And most importantly, it remains possible to independently verify even after Tumbleweed moves on to newer versions. This data is going to stay available as long as anyone pins it on a reachable server. I’m going to pin it as long as it remains relevant to me, so probably a bit until after the next full Tumbleweed rebuild – maybe 6 to 12 months.

Thus, it now is even less easy to sneak in binary backdoors during our package build process.

a silhouette of a person's head and shoulders, used as a default avatar

Falkon, otra alternativa de navegador web para los escritorios Linux






Falkon es un navegador web diseñado para integrarse bien con todos los escritorios Linux comunes, como los escritorios GNOME y KDE Plasma. Es compatible con los estándares web actuales y viene con muchas características, como un bloqueador de anuncios integrado. Anteriormente se conocía como QupZilla.

Si deseas probar un navegador web alterno a Mozilla Firefox, definitivamente Falkon es una gran elección.



Para instalar Falkon en openSUSE, descargamos el paquete desde el portal 



seleccionamos la versión de openSUSE que estemos utilizando y llevamos acabo el proceso de instalación con la opción One Click Install

Una vez instalado, podemos ejecutarlo desde su icono en el submenú de Internet

Have a lot of fun! ¡Diviertete mucho!

a silhouette of a person's head and shoulders, used as a default avatar

Enabling scroll wheel emulation for the Logitech Trackman Marble using Wayland and GNOME 3

For ergonomic reasons, I’ve long used Trackballs as pointing devices instead of regular mice. For several years now, I have been using a Logitech Trackman Marble and a libinput tweak to use the trackball for scrolling by holding down one of the buttons while spinning the ball.

Top view of a Logitech Trackman Marble Trackball

This worked well until some distributions decided to switch to using Wayland as a replacement for X.org. In the past, I have been reverting back to using X.org (by setting WaylandEnable=True in /etc/gdm/custom.conf), as Wayland does not support the required libinput configurations. I found a workaround that creates a shared library that can be preloaded to implement this, but that looked somewhat hacky to me.

But as Wayland seems to be the way forward and my latest distribution upgrade caused some weird X.org issues (my dual-screen setup did no longer work properly), I caved in and switched to Wayland again. At least all of my screens were properly detected afterward, but the scroll wheel emulation was broken. I did some research to see if the libinput support in Wayland had improved in that regard in the meanwhile, but it seems it doesn’t.

However, I found a solution for enabling mouse wheel emulation in Wayland/GNOME3 on the Arch Linux Wiki: simply run the following command in a terminal window:

gsettings set org.gnome.desktop.peripherals.trackball scroll-wheel-emulation-button 8

Now button 8 (the small button above the left button) acts both as a “back” button (e.g., when browsing web pages) as well as the modifier that turns the trackball into a scroll wheel, just like before. Nifty!

the avatar of Michal Čihař

translation-finder 1.1

The translation-finder module has been released in version 1.1. It is used by Weblate to detect translatable files in the repository making setup of translation components in Weblate much easier. This release brings lot of improvements based on feedback from our users, making the detection more reliable and accurate.

Full list of changes:

  • Improved detection of translation with full language code.
  • Improved detection of language code in directory and file name.
  • Improved detection of language code separated by full stop.
  • Added detection for app store metadata files.
  • Added detection for JSON files.
  • Ignore symlinks during discovery.
  • Improved detection of matching pot files in several corner cases.
  • Improved detection of monolingual Gettext.

Filed under: Debian English SUSE Weblate

the avatar of Nathan Wolf

the avatar of Federico Mena-Quintero

A Rust API for librsvg

After the librsvg team finished the rustification of librsvg's main library, I wanted to start porting the high-level test suite to Rust. This is mainly to be able to run tests in parallel, which cargo test does automatically in order to reduce test times. However, this meant that librsvg needed a Rust API that would exercise the same code paths as the C entry points.

At the same time, I wanted the Rust API to make it impossible to misuse the library. From the viewpoint of the C API, an RsvgHandle has different stages:

  • Just initialized
  • Loading
  • Loaded, or in an error state after a failed load
  • Ready to render

To ensure consistency, the public API checks that you cannot render an RsvgHandle that is not completely loaded yet, or one that resulted in a loading error. But wouldn't it be nice if it were impossible to call the API functions in the wrong order?

This is exactly what the Rust API does. There is a Loader, to which you give a filename or a stream, and it will return a fully-loaded SvgHandle or an error. Then, you can only create a CairoRenderer if you have an SvgHandle.

For historical reasons, the C API in librsvg is not perfectly consistent. For example, some functions which return an error will actually return a proper GError, but some others will just return a gboolean with no further explanation of what went wrong. In contrast, all the Rust API functions that can fail will actually return a Result, and the error case will have a meaningful error value. In the Rust API, there is no "wrong order" in which the various API functions and methods can be called; it tries to do the whole "make invalid states unrepresentable".

To implement the Rust API, I had to do some refactoring of the internals that hook to the public entry points. This made me realize that librsvg could be a lot easier to use. The C API has always forced you to call it in this fashion:

  1. Ask the SVG for its dimensions, or how big it is.
  2. Based on that, scale your Cairo context to the size you actually want.
  3. Render the SVG to that context's current transformation matrix.

But first, (1) gives you inadequate information because rsvg_handle_get_dimensions() returns a structure with int fields for the width and height. The API is similar to gdk-pixbuf's in that it always wants to think in whole pixels. However, an SVG is not necessarily integer-sized.

Then, (2) forces you to calculate some geometry in almost all cases, as most apps want to render SVG content scaled proportionally to a certain size. This is not hard to do, but it's an inconvenience.

SVG dimensions

Let's look at (1) again. The question, "how big is the SVG" is a bit meaningless when we consider that SVGs can be scaled to any size; that's the whole point of them!

When you ask RsvgHandle how big it is, in reality it should look at you and whisper in your ear, "how big do you want it to be?".

And that's the thing. The HTML/CSS/SVG model is that one embeds content into viewports of a given size. The software is responsible for scaling the content to fit into that viewport.

In the end, what we want is a rendering function that takes a Cairo context and a Rectangle for a viewport, and that's it. The function should take care of fitting the SVG's contents within that viewport.

There is now an open bug about exactly this sort of API. In the end, programs should just have to load their SVG handle, and directly ask it to render at whatever size they need, instead of doing the size computations by hand.

When will this be available?

I'm in the middle of a rather large refactor to make this viewport concept really work. So far this involves:

  • Defining APIs that take a viewport.

  • Refactoring all the geometry computation to support the semantics of the C API, plus the new with_viewport semantics.

  • Fixing the code that kept track of an internal offset for all temporary images.

  • Refactoring all the code that mucks around with the Cairo context's affine transformation matrix, which is a big mutable mess.

  • Tests, examples, documentation.

I want to make the Rust API available for the 2.46 release, which is hopefully not too far off. It should be ready for the next GNOME release. In the meantime, you can check out the open bugs for the 2.46.0 milestone. Help is appreciated; the deadline for the first 3.33 tarballs is approximately one month from now!

a silhouette of a person's head and shoulders, used as a default avatar

Restaurar la contraseña de root en MariaDB







Para restaurar la contraseña, desde la CLI escribimos los siguientes comandos:

- Detenemos MariaDB 

sudo service mysql stop

- Iniciamos MySQL sin activar la db de MariaDB donde esta la contraseña de root
 
sudo mysqld_safe --skip-grant-tables &amp;

- Accedemos a MariDB sin contraseña 

mysql -u root

- Seleccionamos mysql como base de datos 

<MariaDB [(none)]> use mysql;
<MariaDB [mysql]> update user set password=PASSWORD("mi-nueva-contraseña") where User='root';
<MariaDB [mysql]> update user set plugin="";
<MariaDB [mysql]> flush privileges;
<MariaDB [mysql]> exit

 - Reiniciamos el servicio

sudo service mysql stop
sudo service mysql start


- Accedemos a la BD y comprobamos que los cambios están funcionando

mysql -u root -p

a silhouette of a person's head and shoulders, used as a default avatar

Fortaleciendo un servidor web (Apache2)


Fortaleciendo un servidor web (Apache2) 




La seguridad del servidor web es un tema muy amplio, y diferentes personas tienen diferentes preferencias y opiniones en cuanto a cuáles son las mejores herramientas y técnicas para fortalecer un servidor web en particular. Instalaremos mod_security y mod_evasive, dos módulos muy importantes que pueden proteger a un servidor web Apache contra amenazas comunes, como un ataque de denegación de servicio distribuido (DDOS).

Instalar mod_security y mod_evasive


Desde la línea de comando y con privilegios de super usuario (root), instalamos los dos paquetes :


# zypper in apache2-mod_security2 apache2-mod_evasive

Una vez instalados, los habilitamos para que el sistema los reconozca
 
# a2enmod mod_security2

# a2enmod mod_evasive

Verificamos que se encuentren habilitados

# a2enmod -l actions alias auth_basic authn_core authn_file authz_host authz_groupfile authz_core authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl socache_shmcb userdir reqtimeout enable mysql mariadb apache2 mod_security2 mod_evasive


Reiniciamos el servicio web

 # service apache2 restart


Accedemos a nuestro servidor Apache2 utilizando nuestro navegador web, como podemos ver sin ningún problema el servicio está funcionando.



Presionamos varias veces y de manera rápida y continua el botón de "refresh" en nuestro navegador web y podemos constatar que se nos ha detenido la solicitud de acceso a nuestro servidorApache2. 

Por default, cuando se detectan 3 solicitudes de la misma dirección ip a nuestro servidor en periodos de 6 microsegundos, los módulos security2 y evasive entran en acción para denegar las peticiones, (para que podamos tener acceso nuevamente a nuestro servidor Web, sólo basta con esperar un lapso no mayor a un minuto para intentarlo nuevamente).